[FFmpeg-user] momentary overlay using ffmpeg

Oliver Fromme oliver at fromme.com
Mon May 19 10:39:45 CEST 2014


tarun singhal wrote:
 > When using overlay or drawtext filter, I see that it applies overlay/text
 > over complete length of video.
 > I have a requirement where I want to put an overlay or draw text on source
 > video, but the overlay should appear only from lets says start time code:
 > 00:02:00 and should remain there till 00:02:10
 > 
 > So, basically having overlay only for 10 seconds in the source video?
 > 
 > Is this possible to do with ffmpeg?

Yes.  I use the following trick to stop a subtile overlay
at a certain timestamp,

-filter_complex "[0:v][1:s]overlay=x='if(gt(t,300.0),NAN,0)'"

The effect is that the x offset is set to NAN ("not-a-number")
when the current time (t) is greater than ("gt") 300 seconds.
When the overlay's x offset is NAN, it becomes invisible.
The default for the x offset is 0, which puts the overlay at
the normal position.

In your case you probably want something like this:

overlay=x='if(between(t,120.0,130.0),0,NAN)'

So the x offset is set to 0 (normal) when the time is between
120 seconds (2:00) and 130 seconds (2:10).  Outside of that
interval it is set to NAN, so the overlay becomes invisible.

Best regards
   Oliver


-- 
``We are all but compressed light'' (Albert Einstein)



More information about the ffmpeg-user mailing list