Home > Blockchain >  Batch ffmpeg conversion
Batch ffmpeg conversion

Time:09-14

I'm looking to batch draw text using ffmpeg on a directory of mp4s. Basically, take the mp4s from the old directory and drop the newly minted mp4s in the new directory. In this case, there are 20 chunks (0 to 19, chunk_x.mp4). I haven't been able to implement the existing solutions on stack.

ffmpeg -i old/chunk_9.mp4 -vf 
"drawtext=fontfile=Arial.ttf: text='%{frame_num}': start_number=1: x=(w-tw)/2: y=h-(2*lh): 
fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=5" 
-c:a copy new/chunk_9.mp4

CodePudding user response:

You dont need python. You can just do a for loop in bash:

for i in {1..20}
do

ffmpeg -i old/chunk_${i}.mp4 -vf 
"drawtext=fontfile=Arial.ttf: text='%{frame_num}': start_number=1: x=(w-tw)/2: y=h-(2*lh): 
fontcolor=black: fontsize=20: box=1: boxcolor=white: boxborderw=5" 
-c:a copy new/chunk_${i}.mp4

done
  • Related