You only need the -ss and -t options. -ss is the starttime and -t the duration, so if you want 10 seconds from a video starting from minute one, you would use this.
1
| ffmpeg -i INFILE.mp4 -vcodec copy -acodec copy -ss 00:01:00.000 -t 00:00:10.000 OUTFILE.mp4 |
You can use seconds or hh:mm:ss[.xxx] as arguments for the start time and duration, i prefer the second option.
The options -vcodec copy and -acodec copy are used to only cut the video and disable the re-encoding, this really speed things up.
I use this commandThe options -vcodec copy and -acodec copy are used to only cut the video and disable the re-encoding, this really speed things up.
ffmpeg -i INFILE.mp4 -vcodec copy -acodec copy -ss 00:01:00.000 -t 00:00:10.000 OUTFILE.mp4
ffmpeg -i "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-RFTYZgBNprg.mp3" -vcodec copy -acodec copy -ss 00:00:10.000 -t 01:00:00.000 "NON STOP CHRISTMAS MEDLEY VOLUME 1 & 2-1 hours.mp3"
without re-encoding
Install ffmpeg
Make sure you download a recent version of
ffmpeg , and don't use the one that comes with your distribution (e.g. Ubuntu). Packaged versions from various distributions are often outdated and do not behave as expected.How to cut a video, without re-encoding
Use this to cut video from
[start] for [duration] :
Here, the options mean the following:
Note that with older ffmpeg versions, this command may not be frame-accurate when copying the bitstreams.
How to cut a video, without re-encoding — accurate method
If you have an old ffmpeg version and you want frame accuracy, use this instead:
However, there's one drawback. The video will have to be decoded until it reaches the position implied by
-ss , and only then it starts copying the bitstream. This can take a long time, especially for really long videos.How to cut a video, with re-encoding
If you leave out the
-c copy option, ffmpeg will automatically re-encode the output video and audio according to the format you chose. For high quality video and audio, read the x264 Encoding Guide and the AAC Encoding Guide, respectively.
For example:
As explained by Seeking with FFmpeg): When using
-ss before -i on FFmpeg 2.1 and newer, seeking is frame-accurate when re-encoding the video (i.e., not using -c copy ). So you don't have to worry about putting -ss after -i for speed.Converting end points to duration
If you need to use an old version of
ffmpeg and can't use the -to option, you can create an edit list of in and out points, and convert these into in points with duration. For this you can use this Ruby script I wrote, which calculates the difference:
For example:
| |||||||||||||||||||||
|
6
|
I think you can use the following command now.
Have a look also ffmpeg Doc, or this wiki page.
| ||||
|
2
|
You can use these two methods which work for Windows and Linux.
| ||||||||||||
|
1
|
This is odd that no-one suggested the
trim filter.
Drop everything except the second minute of input:
Keep only the first second:
Drop everything except from second 13 to second 58:
| ||||
|
-1
|
You can use this
Here you have to give duration of video. ie. 00:25:33-00:09:23
| ||||
|
-2
|
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.
|