Completely new to working with FFMPEG, what I'm trying to achieve is applying overlaying graphics at certain positions and times, and cutting out sections of a single input video.
I've worked out the overlaying graphics, so this code is working:
ffmpeg -i /Users/username/projectdir/static/video.mp4 -I overlay.png -i overlay2.png -filter_complex "[0:v][1:v] overlay=192:108:enable='between(t, 0, 5)'[ov0]; [ov0] overlay=192:108:enable='between(t, 5, 10)'" -pix_fmt yuv420p output_overlayed.mp4 But when I try to cut out sections using this code:
ffmpeg -i /Users/username/projectdir/static/video.mp4 -I overlay.png -i overlay2.png -filter_complex "[0:v][1:v] overlay=192:108:enable='between(t, 0, 5)'[ov0]; [ov0] overlay=192:108:enable='between(t, 5, 10)', select='between(t,0,5)+between(t,10,15)', setpts='N/FRAME_RATE/TB'" -pix_fmt yuv420p output_overlayed_trimmed.mp4 It seems to cut correctly, so the original video starts playing from 0 seconds until 5 seconds and then plays from 10 seconds in until 15 seconds and cuts out. But after the point where the video cuts out it's just a black screen for the duration of the video. I can't seem to get it to work so it affects the overall duration of the video.
(The values being passed in are just examples by the way, eg. I've got it to start an overlay 5 seconds in but also cut 5 seconds in)
I have the timestamps for when the overlays should appear on the non-trimmed video, so the overlaying should happen first and then the trimming. If the video is trimmed first then the overlays will appear at the wrong times.
An alternative way of achieving this that is currently working is by performing the first line of code (which just produces a new video file with the overlay) and then separately take this new file and perform the trimming independently:
ffmpeg -ss 0 -to 5 -i /Users/username/projectdir/static/output_overlayed.mp4 -ss 15 -to 20 -i /Users/username/projectdir/static/output_overlayed.mp4 -filter_complex "[0][1]concat=n=2:v=1:a=1" output_trimmed.mp4
But this means working with 2 separate files and then having to remove the first after the 2nd execution is complete. Ideally I'd combine them into one command which doesn't produce multiple files.
Would appreciate any help - thanks!


