← Back to all articles
Blog

ffmpeg watermarks like Douyin: top-left for one period, bottom-right for another

Videos downloaded from Douyin receive an intro and image watermark. The watermark appears at top-left during the first half, then disappears and appears at bottom-right through the end.

Burning in a watermark that changes position is simple:

Use ffprobe to retrieve duration and calculate half of it. Use ffmpeg to display the top-left watermark for the first half, then delay the bottom-right watermark until halfway and keep it for the remaining half.

Example

Video a lasts 100 seconds. Show top-left from 10S for 40 seconds, then remove it at 50 seconds and show bottom-right through the end.

Implementation

  • One: Retrieve duration with ffprobe, returning 100 seconds.
  • Two: Write ffmpeg arguments. The first top-left watermark starts after 10 seconds and lasts 40% of the video. The second bottom-right watermark starts at 50% and lasts 50% of the video.
  • Three: Assemble the command and burn it in with ffmpeg.

Command example

ffmpeg -i input.mp4 -i watermark.png -i watermark2.png -filter_complex "[0:v][1:v] overlay=10:10:enable='between(t,10,50)' [tmp]; [tmp][2:v] overlay=W-w:H-h:enable='between(t,51,100)'" output.mp4

Future EFV updates

I will integrate this design so users customize watermark appearance and timing, adapting to video duration.

Future fluentEFV API services will return downloadable streams from m3u8 with preview support: without permission, generate only a 1-minute FLV stream. Other services will return screenshots at a requested time, animations with chosen start, duration and dimensions, an audio-only section, or a video-only section with specified dimensions. Stay tuned.