0

How do I encode multiple video files in one batch with ffmpeg, using the same settings?

I found this one-line solution that converts .avi files in the current folder to .mov. Note that I want to encode .mov -> .mov :

for i in *.mov; do ffmpeg -i "$i" "${i%.mov}.mov" ; done

I wish to use the following settings for encoding:

ffmpeg -i "$i" -c:v libx265 -preset ultrafast -crf 20 -af "volume=25dB, highpass=f=200, equalizer=f=50:width_type=h:width=100:g=-15" -c:a aac -strict experimental -b:a 192k OUTPUT-ENCODED.MOV

Possible ways to prevent overwriting:

  • Add -ENCODED to the end of the filename before the file extension
  • Rename the files to something sequential, like OUTPUT01.MOV, OUTPUT02.MOV, etc
  • Put the encoded files in a directory subfolder but with the same file names
Community
  • 1
  • 1
P A N
  • 5,642
  • 15
  • 52
  • 103

1 Answers1

1

You can freely manipulate the output file ${i%.mov}.mov - here, the "key ingredient" is that the statement ${i%.mov} yields content of variable i with the shortest match of .mov deleted from the back. For details see this tutorial on manipulating strings in bash.

ewcz
  • 12,819
  • 1
  • 25
  • 47
  • Thanks for clarifying. This is what I did: `for i in *.MOV; do ffmpeg -i "$i" -c:v libx265 -preset ultrafast -crf 20 -af "volume=25dB, highpass=f=200, equalizer=f=50:width_type=h:width=100:g=-15" -c:a aac -strict experimental -b:a 192k "${i%.MOV}-ENCODED.MOV"; done` – P A N Nov 21 '15 at 11:26