I have a video file of 30 minutes, but I want to extract a video from 00:09:23 to 00:25:33. I can define the startposition with -ss, but I couldn't find one for the end position. Any help please?

link|improve this question
feedback

3 Answers

The other answer are partly right. However, to just extract a part of a video, and not re-encode it while doing so, you can't use the -sameq option. Forget that one, it just tries to get the same quality from an input, while unnecessarily increasing the output file size, when in fact you can just copy the video. In general, using -sameq is really bad advice. Therefore, use -vcodec copy.

So, this would mean:

ffmpeg -i in.mp4 -ss [start] -t [duration] -vcodec copy -acodec copy out.mp4

However, there's still one drawback. The video will be decoded until it reaches the position implied by -ss. This can take a long time, especially for really long videos.

For additional speed when doing this, you can supply the -ss option before -i. This way, the decoder will first seek to the position and then start decoding:

ffmpeg -ss [start] -i in.mp4 -t [duration] -vcodec copy -acodec copy out.mp4

If you have an edit list of in and out points, and want to convert these into in points with duration, you can use this Ruby script I wrote, which calculates the difference:

require "Time"
def time_diff(time1_str, time2_str)
  t = Time.at( Time.parse(time2_str) - Time.parse(time1_str) )
  (t - t.gmt_offset).strftime("%H:%M:%S.%L")
end

For example:

time_diff("00:09:23.000", "00:25:33.000")
=> "00:16:10.000" 
link|improve this answer
feedback

I use the following syntax to cut video with ffmpef:

ffmpeg -sameq -ss [start_seconds] -t [duration_seconds] -i [input_file] [outputfile]

-t is used to set the duration in seconds - you can't specify the end time but this should work for you.

link|improve this answer
Why are you setting FFmpeg to re-encode the file? Note that -sameq does not mean "same quality" at all. – slhck Jan 11 at 21:18
feedback

You can use this

ffmpeg -sameq -ss clip_start -t duration  -i  original.ogg  clip.ogg

Here you have to give duration of video. ie. 00:25:33-00:09:23

link|improve this answer
As I mentioned on the other answer: Do you know that -sameq does not mean "same quality" at all? With your command, you're re-encoding the file, which is absolutely not necessary and results in reduced quality and increased processing time. – slhck Jan 11 at 21:18
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.