Search code examples
ffmpegvideo-processingandroid-ffmpeg

FFmpeg: Trim video then add watermark with multiple text


I want to trim a video then convert a video using FFMPEG and place a watermark with multiple texts on it. I have commands for trimming :

ffmpeg -i 1.mp4 -ss 00:00:03 -t 00:03:08 -async 1 -c copy output1.mp4

and for watermark with text placing

ffmpeg -i 1.mp4 -i watermark_small.png -filter_complex "[0:v][1:v]overlay=10:10, drawtext=enable='between(t,0,12)':fontfile=font.ttf:text='Some text' : fontcolor=black: fontsize=18: box=1: [email protected]:boxborderw=5: x=(w-text_w)/1.15:y=30, drawtext=enable='between(t,14,22)':fontfile=font.ttf:text='Next text' : fontcolor=black: fontsize=18: box=1: [email protected]:boxborderw=5: x=(w-text_w)/1.15:y=30" -codec:v libx264 -preset ultrafast output1.mp4

Can someone help me to combine them together?


Solution

  • Use

    ffmpeg -ss 00:00:03 -t 00:00:08 -i 1.mp4 -i watermark_small.png -filter_complex 
      "[0:v][1:v]overlay=10:10, 
       drawtext=enable='between(t,0,12)':fontfile=font.ttf:text='Some text' : fontcolor=black:
       fontsize=18: box=1: [email protected]:boxborderw=5: x=(w-text_w)/1.15:y=30,
       drawtext=enable='between(t,14,22)':fontfile=font.ttf:text='Next text':fontcolor=black:
       fontsize=18: box=1: [email protected]:boxborderw=5: x=(w-text_w)/1.15:y=30"
    -c:v libx264 -preset ultrafast output1.mp4