Reputation: 5791
I am looking to add the color filter to a rtmp stream in ffmpeg at specific time intervals, say for 10 seconds every 10 seconds. I have tried two approaches. The first:
-vf "color=#[email protected]:480x208,select='gte(t,10)*lte(t,20)' [color];[in][color] overlay [out]"
This streams only the 10 seconds indicated by the select and applies the color filter rather than playing the whole stream and applying the filter to just those 20 seconds.
I then learnt about split and fifo and tried this approach:
-vf "[in] split [no-color], fifo, [with-color] overlay [out]; [no-color] fifo, select='gte(t,10)*lte(t,20)' [with-color]"
I would expect this to play the entire stream, and then select the 10 seconds specified so that I can apply filters, but it does the same as first approach and just plays the 10 seconds selected rather than the entire stream.
Thanks in advance.
Upvotes: 1
Views: 2919
Reputation: 11
I'm dealing with similar problem, I used combination of filter slpit, overlay and concat, and it works, you can try it.
-filter_complex "[0:v]split[v1][v2];[v1]select='lt(t,5)',setpts=PTS-STARTPTS[iv1];[v2]select='gte(t,5)'[over];[over][1:v] overlay=W-w:H-h:shortest=1,setpts=PTS-STARTPTS[iv2];[iv1][iv2]concat=n=2:v=1:a=0"
but my problem is, I use gif as second input because it contains transparent color information, but gif file dosn't not contain audios. how can I make a movie with both transparent(or alpha) and audio?
Upvotes: 1
Reputation: 33991
As this question discusses, there doesn't appear to be a way to apply video filters to a specific time period of a video stream, short of splitting it into pieces, applying filters, and recombining. Please share if you find a better method.
Upvotes: 3
Reputation: 544
You changed the order of the streams going into the overlay.
It seems that if a "select
"ed stream goes as first input to the overlay
filter, overlay also blanks out its output in the non-selected times.
But if you first provide a stable stream to overlay
and then the selected, it will output a stream for the whole time.
I tried following set of filters:
-vf "[in]split[B1][B2];[B1]fifo,drawbox=-1:-1:5000:5000:invert:2000,vflip,hflip[B1E];[B2]fifo,select='gte(t,5)'[B2E];[B1E][B2E]overlay[out]"
My version as graph:
_,--[B1]--fifo--drawbox--flip--[B1E]--._
[in]---split--X X--overlay--[out]
‾'--[B2]--fifo--select---------[B2E]--'‾
Your version was (the select filter is the first overlay
input!!):
_,--fifo--select---[with-color]--._
[in]---split--X X--overlay--[out]
‾'--[no-color]--fifo-------------'‾
The reason is that
...[B2E];[B1E][B2E]overlay...
and
...,[B1E]overlay...
are equivalent.
But nevertheless there may remain some problems: Do you need the one time or every 10 seconds, e. g.?
Upvotes: 3