How to add text, image, colour and timer overlays on videos using FFmpeg

Want to make your videos look like TV news broadcasts?

Today, I used some filters on a public-domain video to add several kinds of overlays. My ffmpeg command was:

ffmpeg -y -i t.png -i t.mp4 \
       -filter_complex \
         "color=color=FF000066:s=1280x80:d=5,
          drawtext=x=20:y=(H-th)/2:fontcolor=ghostwhite:shadowcolor=black: shadowx=2:shadowy=2:text='How elections are stolen in the USA':fontsize=60:fontfile=${HOME}/.fonts/Billboard.ttf[t];
          color=color=FFFFFF00:s=1280x720:d=5[f];
          [f][t]overlay=x=0:y=H-h-20[o];
          [o][0:v:0]overlay=x=W-w-20:y=20:repeatlast=1[of];
          [1:v:0][of]overlay=x=0:y=H-h:repeatlast=1,
          drawtext=x=W-tw-20:y=H-th-30:
         fontfile='${HOME}/.fonts/Time-Normal.ttf':
         fontsize=round(H/30):fontcolor=FFFFFF77:
         text='%{eif\:mod(t/3600\,60)\:d\:2}\:%{eif\:mod(t/60\,60)\:d\:2}\:%{eif\:mod(t\,60)\:d\:2}'[v];
          [1:a:0]asetpts=PTS-STARTPTS,dynaudnorm=gausssize=3[a]" \
       -map '[v]' -map '[a]' \
       -c:v libx264 -crf 21 -preset medium -tune film  \
       -c:a libfdk_aac -vbr 5 \
       How-elections-are-stolen-in-the-USA.mp4 && \
       xdg-open How-elections-are-stolen-in-the-USA.mp4

The filters

  1. color — Draws a translucent red background for the width of the video (t.mp4). Its duration is 5 seconds.
  2. drawtext — Renders some text on the colour background for the same duration as above.
  3. color — Creates a transparent frame that is the same size as the video.
  4. overlay — Places the text and its red background on the frame.
  5. overlay — Places the book image (t.png) on the frame from previous step.
  6. overlay — Places the frame with overlaid text, red band and book image on the video (t.mp4).
  7. drawtext — Draw the timer.
  8. asetpts — Rewrite timestamps.
  9. dynaudnorm — Autolevel volume.

Screenshot of video player

Demo video

Apart from the overlays, the low volume in the original video has been fixed in my ‘filtered’ video.

Rumble

The original video

Youtube


Become an FFmpeg PRO by reading my book Quick Start Guide to FFmpeg.

Book photo

Link: | Magic Link:

Comments are not enabled yet.

For older posts, check the archives.