FFmpeg - Enable all video filter (-vf) options at a specific time in the video
Is there an option I can pass so that my -vf or -filter_complex options only become active at a certain time in the video (i.e. 5 seconds after the start of a video?) in one command (without concat'ing two different video files)?
Something like this:
ffmpeg -i input.mp4 -vf "eq=contrast=250.0, time=start=5:end=15" output.mp4Where the contrast filter would only appear on the video from 5 to 15 seconds in.
Maybe I could concat two separate videos in one line? Any guidance would be appreciated, thanks.
Edit: just read the Timeline Editing section in the ffmpeg docs - but as I understand, not all filters support this. Is there a universal method?
1 Answer
If the filter supports timeline editing, then you can set the enable keyword for that filter, e.g.
ffmpeg -i input.mp4 -vf "eq=contrast=250.0:enable='between(t,5,15)'" output.mp4If it doesn't, then you can use a combination of split, trim and concat filters to segment the input for selective processing.
ffmpeg -i input.mp4 -vf "split=3[pre][affected][post];[pre]trim=0:5,setpts=PTS-STARTPTS[pre];[affected]trim=5:15,setpts=PTS-STARTPTS,eq=contrast=250.0[affected];[post]trim=15,setpts=PTS-STARTPTS[post];[pre][affected][post]concat=n=3:v=1:a=0" output.mp4