Search code examples
ffmpegvideo-processingdrawtextfluent-ffmpeg

Run FFMPEG multiple overlay commands in one command


I'm using ffmpeg to do more operation on one video
the operation that i want to do is add many text in difference time, audio and image. i can do all of them but not in one command, Do all separately

any suggestions to do multiple text , overlay image and audio in one command

Thanks


Solution

  • To achieve the commands provided in comments in one execution, use

    ffmpeg –i input.mp4 –i img.png -i audio.mp4 -filter_complex \
           "[0:v][1:v]overlay=15 :15:enable=between(t,10,20), \
            drawtext=enable='between(t,12,3*60)': \
            fontfile=/usr/share/fonts/truetype/freefon‌​t/FreeSerif.ttf: text='Test Text'[v]" \
           -map "[v]" -map 2:a -acodec copy -qscale 4 -vcodec mpeg4 outvideo.mp4
    

    To add more drawtext filters, insert them after the first drawtext filter e.g.

    ffmpeg –i input.mp4 –i img.png -i audio.mp4 -filter_complex \
           "[0:v][1:v]overlay=15 :15:enable=between(t,10,20), \
            drawtext=enable='between(t,12,3*60)': \
            fontfile=/usr/share/fonts/truetype/freefon‌​t/FreeSerif.ttf: text='Test Text', \
            drawtext=enable='between(t,12,3*60)': \
            fontfile=/usr/share/fonts/truetype/freefon‌​t/FreeSerif.ttf: text='Text2'[v]" \
           -map "[v]" -map 2:a -acodec copy -qscale 4 -vcodec mpeg4 outvideo.mp4