Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fastest way to Add Image into Video using FFMPEG at First 20 Seconds

Tags:

ffmpeg

Anyone knows the fastest way to add image into video at first 20 seconds? I have tried it, but it seemed like FFMPEG re-encoded the whole video even after 20 seconds which took a long time..

here my code:

ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=5:5:enable='between(t,0,20)'" output.mp4
like image 776
RaiN Avatar asked Jan 26 '26 05:01

RaiN


1 Answers

Fast

Use a faster -preset and stream copy (re-mux) the audio instead of re-encoding it:

ffmpeg -i input.mp4 -i logo.png -filter_complex "overlay=5:5:enable='between(t,0,20)'" -preset fast -c:a copy output.mp4

Faster

You could encode the ~20 segment conforming to the same parameters as the main input, then concatenate with the concat demuxer in stream copy mode. However, this will be troublesome because conforming parameters is not trivial for most users, the concat inpoint directive is not guaranteed to seek accurately with non-intra inputs, and you could end up with timestamp issues anyway.

Fastest

The most fastest way is to use a player to overlay the logo:

mpv --lavfi-complex="[vid1][vid2]overlay=5:5:enable='between(t,0,20)[vo]" video.mp4 --external-file=image.png
like image 59
llogan Avatar answered Jan 29 '26 13:01

llogan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!