Reputation: 3502
I'd like to extract a slice of video from a video. Unfortunately, I do not have the start time position and duration to run ffmpeg like so:
ffmpeg -sameq -ss [start_seconds] -t [duration_seconds] -i [input_file] [outputfile]
Instead, I have the first and the last frame number. So... is it possible to slice a mp4 video with ffmpeg based on frame position?
Upvotes: 9
Views: 16322
Reputation: 93329
If the file has audio, which also needs to be correspondingly sliced, then you will need to know the start time and duration. Unless the video is variable frame rate, start frame index I
is at time I/FPS
and end frame O
is at time O/FPS
where FPS is the frame rate of the video. Running ffprobe [input_file]
will give you the frame rate reading.
Else use,
ffmpeg -i input.mp4 -vf trim=start_frame=I:end_frame=O+1 -an output.mp4
-sameq
is deprecated and does not mean same quality. This command will skip the audio as it can't be cut with reference to video frame indices.
Upvotes: 8