Cut an FFmpeg video based on frames not a timecode

0

I want to cut a video with FFmpeg using something similar to the code below:

ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4

However I want to specify -ss and -t in frames instead of in seconds. For example, instead of 3 seconds I would want to tell ffmpeg to start the cut at 90 frames. I want to do this because I am going to be cutting videos using a script and I don't want to overcomplicate things by having to convert the frame numbers into seconds before passing it to FFmpeg.

Simply specifying a number like -ss 90 starts the cut at 90 seconds in, not at 90 frames.

mxbi

Posted 2015-08-12T12:19:21.357

Reputation: 191

Answers

3

I believe you should be able to accomplish this using the select filter. However, when using a video filter, you will no longer be able to stream copy - instead, you will have to transcode the file by choosing a codec with the c:v flag.

For example, to create a cut starting at the 90th frame, and producing an output that is 1000 frames long, and transcoding the output into an H264 format, you could try:

ffmpeg -i [INPUT] -vf select=gte(n\,90) -vframes 1000 -c:v libx264 -f mp4 [output.mp4]

occvtech

Posted 2015-08-12T12:19:21.357

Reputation: 980

0

There is no way to do exactly what you are asking.

You can use -frames to process a desired number of frames but using a frame number as the starting position isn't possible.

dstob

Posted 2015-08-12T12:19:21.357

Reputation: 305

So would -frames replace -t here? – mxbi – 2015-08-12T14:57:06.150