[FFmpeg-user] Cut-edits with ffmpeg
expandafter at yahoo.com
Fri Jul 26 13:09:41 CEST 2013
On Thu, 7/25/13, Carl Lindqvist <lulebo at gmail.com> wrote:
> I've just started experimenting using the select filter to do this.
> You can use select in combination with between and the "n" parameter
> to select a bunch of frames to cut/keep. Right now I use aselect to do
> the same thing on the audio. Not sure if it's needed, haven't done
> much testing. Here is an example that will encode frames 0-100 and
> 130-200 to the output:
> ffmpeg.exe -i SOURCEFILE.avi -vf
> -c:v libx264 -preset veryfast -b:v 700k -profile:v main -af
> aselect='-between(n,0,100)-between(n,130,200)',asetpts=N/SR/TB -c:a
> libvo_aacenc -b:a 96k -ac 2 OUT.mp4
> I'm not yet sure if between 0-100 means that it will keep frame 0 and
> 100 or if it means 1 to 99, but I think it is 0 to 100.
Look at my post of Jul 18 again:
> It can be done using the filters select, aselect, setpts, and asetpts.
> Let's say you want to keep only two segments: the one starting at
> 5 seconds and ending at 20 seconds, and the one between 40 seconds
> and 52 seconds.
> ffmpeg -i "sample.avi" -vf select='-between(t,5,20)-between(t,40,52)',setpts=N/FRAME_RATE/TB
> -af aselect='-between(t,5,20)-between(t,40,52)',asetpts=N/SR/TB sample.mp4
When you say
the numbers 130 and 200 refer to seconds, not frames.
The "aselect" is necessary.
I've since decided that negative numbers aren't a good idea.
ffmpeg -i "sample.avi" -vf select='between(t,5,20)+between(t,40,52)',setpts=N/FRAME_RATE/TB
-af aselect='between(t,5,20)+between(t,40,52)',asetpts=N/SR/TB sample.mp4
More information about the ffmpeg-user