I'm trying to add overlays to an input video with ffmpeg that appear some time after the video starts.
The basic way to add an overlay is:
ffmpeg -i in.avi -vf "movie=overlay.avi [ovl]; [in][ovl] overlay" out.avi
But this adds the overlay video (or image) from the start of the input video until one of the videos ends.
I know how to offset the overlay video using movie=overlay.avi:seek_point=1.4
, but what about an offset on the input video?
I could always clip the video to the desired point, add overlay on the second clip, then stitch the two but that's not very efficient.
FFmpeg offers the overlay filter as a way to overlay images (or even other videos) onto video streams. To centre overlay/watermark on a video, use this command: ffmpeg -i inputvideo.avi -i watermarklogo.png -filter_complex \ "overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy output.flv.
Expanding on arttronics' insightful, but speculative answer, video can indeed be easily be overlaid offset using the -itsoffset
flag.
The -itsoffset
flag works like so:
-itsoffset offset (input)
Set the input time offset in seconds. [-]hh:mm:ss[.xxx] syntax is also supported. The offset is added to the timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by offset seconds.
(NB: Despite the phrase "input files", the flag actually applies only to the input immediately following it. Note also this bug about offsets not applying to audio streams. H/T attronics.)
So overlaying with an offset is as simple as:
ffmpeg -i bg.avi -itsoffset 2 -i over.avi -filter_complex overlay out.avi
This works regardless of the container type.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With