0

I've searched for days to find this solution. All i found was ways to add the logo the first seconds or after a few seconds or only between certain parts (for example between 30 and 210 seconds)

So the main question is: How to add my logo for the last 60 seconds in a video with ffmpeg? I have a lot of videos all different lengths and simply want the last 60 seconds to overlay with a .png logo (in this case also at the left bottom of the screen)

Currently i'm using what you see below which works fine (shows logo always except between 30-210 seconds of videos) but like i mentioned in title, it does not do exactly do what i want.

-i video.mp4 -vf "movie=/logo.png [watermark]; [in][watermark] overlay=1:main_h-overlay_h-1:enable=not(between'(t,30,210)') [out]"
razz
  • 41

2 Answers2

2

There is a, likely inefficient, method to do this that worked here in a test but may fail when input timestamps are irregular i.e. start from non-zero.

Basic template is

ffmpeg -i in.mp4 -sseof -60 -copyts -i in.mp4 -loop 1 -i logo.png -filter_complex "[1][2]overlay=shortest=1[logo];[0][logo]overlay" out.mp4

The video is inputted twice. In the 2nd input, the sseof option is set which allows one to seek using a time interval measured from the end. Of course, unless specified otherwise, FFmpeg will reset input timestamps, so copyts is set to preserve input TS.

First, the logo is overlaid on the trimmed video, and that result overlaid on the first input. Since timestamps are preserved, the frames are in alignment and the purpose is achieved.

Gyan
  • 38,955
1

overlay and enable do not have the ability to reference the end or duration of the video. You'll need to use an additional command (probably ffprobe and grep, such as described in this answer) to extract the duration then use that to generate the ffmpeg command with the right between values.

Ouroborus
  • 2,850