Input

Null input

-f lavfi -re -i nullsrc=s=1280x720

Overlay

https://ffmpeg.org/ffmpeg-filters.html#overlay-1

Add watermark

-i video.mp4 -i logo.png -filter_complex "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2"
  • TOP LEFT: overlay=5:5
  • TOP RIGHT: overlay=main_w-overlay_w-5:5 or overlay=W-w-5:5
  • BOTTOM LEFT: overlay=5:main_h-overlay_h or overlay=5:H-h-5
  • BOTTOM RIGHT: overlay=main_w-overlay_w-5:main_h-overlay_h-5 or overlay=W-w-5:H-h-5
  • TOP RIGHT(Scale): [1:v]scale=32:48 [ovrl],[0:v][ovrl]overlay=W-w-15:15

  • RGB Colorspace: overlay=5:H-h-5:format=rgb,format=yuv420p

With text:

-f video.mp4 -i logo.png -filter_complex "[1:v]scale=155:29 [ovl],[0:v][ovl]overlay=15:H-h-20 [v];[v]drawtext=text='liulantao.com':fontcolor=white:shadowcolor=black:fontsize=24:x=w-tw-15:y=h-lh-20:" \

Add timestamp

-vf "drawtext=text='%{localtime\:%Y/%m/%d %T}': fontsize=48: x=(w-tw)/2: y=h-(2*lh):"
ffmpeg -f lavfi -re -i nullsrc=s=1280x720 -vf "drawtext=text='%{localtime\:%Y/%m/%d %T}': fontsize=48: x=(w-tw)/2: y=h-(2*lh):" -c:v libx264 -preset veryfast -pix_fmt yuv420p -g 50 -f flv rtmp://127.0.0.1/live/test

Mulitple channel using same filter - Use -map

ffmpeg -re -i "${SRC}" \
  -i ~/logo.png \
  -filter_complex "[1:v]scale=185:40 [ovl],[0:v][ovl]overlay=1000:H-h-600[v];[v]drawtext=text='liulantao.com':fontcolor=white:shadowcolor=black:fontsize=30:x=w-tw-15:y=h-lh-10:,split=2[s480p][s720p]" \
  -map '[s480p]' -map 0:a -c:v libx264 -preset veryfast -b:v  512k -maxrate  640k -bufsize 1000k -pix_fmt yuv420p -g 50 -s  854x480 -c:a aac -b:a 64k -strict -2 -f flv "${LIVE_SERVER}${NAME}-480p" \
  -map '[s720p]' -map 0:a -c:v libx264 -preset veryfast -b:v 1000k -maxrate 1000k -bufsize 1500k -pix_fmt yuv420p -g 50 -s 1280x720 -c:a aac -b:a 96k -strict -2 -f flv "${LIVE_SERVER}${NAME}-720p"

Creating Multiple Outputs