0

ffmpeg remove multiple segments from a video rotate and crop video

I have a video of 2 min 25 seconds , i want to remove part from 10 second to 16 second and 20 second to 26 second and rotate video and crop it

I am trying this command

 "-y", "-i", j,
                      "-filter_complex",
                        "[0:v]trim=start=10:end=16,setpts=PTS-STARTPTS[a];  " +
                                "[0:v]trim=start=20:end=26,setpts=PTS-STARTPTS[b]; " +
                                "[0:a]atrim=start=10:end=16,asetpts=PTS-STARTPTS[c]; " +
                                "[0:a]atrim=start=20:end=26,asetpts=PTS-STARTPTS[d]; " +
                                "[a][c][b][d]concat=n=2:v=1:a=1[e][f],"+
                                "crop=" + 40 + ":" + 20 + ":" + 100 + ":" + 100,"+
                                "transpose=1", "-map", "'[e]'" ,"-map",
                        "'[f]'", "-preset", "ultrafast",out

what is the correct command to do it

1 Answer 1

2

For the filtering, use

ffmpeg -y -i in
 -filter_complex,
       "[0:v]select='not(between(t,10,16)+between(t,20,26))',setpts=N/30/TB,crop=40:20:100:100,transpose=1[v];
        [0:a]aselect='not(between(t,10,16)+between(t,20,26))',asetpts=N/SR/TB[a]"
 -map '[v]' -map '[a]' -b:v 2097k -r 60 -vcodec mpeg4 out.mp4

(Drop the transpose filter if the video comes out rotated. It's because ffmpeg is autorotating the video beforehand.

The trim filter keeps the specified segment in and removes everything else. You want to do the reverse. That can also be done with multiple trim filters, but a single select filter is more convenient.

Sign up to request clarification or add additional context in comments.

16 Comments

i tried follwoing command "-y", "-i", j, "filter_complex", "[0:v]select='not(between(t,10,16)+between(t,20,26))',setpts=PTS-STARTPTS," + "crop=40:20:100:100,transpose=1[v];" + "0:a]aselect='not(between(t,10,16)+between(t,20,26))',asetpts=PTS-STARTPTS[a]","-map", "'[e]'", "-map","'[f]'", "-preset", "ultrafast", out, as you suggested, I am getting error Metadata:creation_time : 2017-11-01 17:32:41handler_name : SoundHandle[NULL @ 0xac915f90] Unable to find a suitable output format for 'filter_complex'
You skipped the - in -filter_complex.
sorry newbie error still learning about ffmpeg, your guidance is helpful
the command is executed, but i still get only the rotated video, I must not framed the question correctly, what i want to do is remove that part of video between seconds 10 and 16 , and create a new video, which should not have these parts, instead i get the same 2 min 25 sec video, it should be without those 6 seconds how can that be done
Did you map [v] and [a] and remove [e] and [f]?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.