Splitting video in multiple episodes with ffmpeg

6

1

I need to cut one video into multiple pieces with ffmpeg.

When I cut just one episode

ffmpeg -i 001.mp4 -vcodec copy -acodec copy -ss 00:00:00.000 -t 00:00:25.500 -strict -2 out1.mp4

or

ffmpeg -i 001.mp4 -vcodec copy -acodec copy -ss 00:00:25.500 -t 00:00:33.750 -strict -2 out2.mp4

my video is cut instantaneously.

But when I chain markers where I'd like to cut

ffmpeg -i 001.mp4 -vcodec copy -acodec copy -ss 00:00:00.000 -t 00:00:25.500 -strict -2 out1.mp4 -ss 00:00:25.500 -t 00:00:33.750 -strict -2 out2.mp4

it still works, but it takes considerably more time (about 10 sec), and I see the same output as when I convert something.

Is something wrong with my ffmpeg-command, or it is better to execute ffmpeg-commands one by one?

Alex Smolov

Posted 2013-06-12T00:21:36.290

Reputation: 175

1Don't reask, it will be better long term if you just let moderator;s migrate it. I have already flagged it, but if it gets closed without moving, just flag it yourself and ask a mod to move it. – psubsee2003 – 2013-06-12T00:27:26.647

Answers

5

ffmpeg is probably re-encoding out2.mp4 because you did not include your copy options for your second output:

ffmpeg -i 001.mp4 -codec copy -t 00:00:25.5 out1.mp4 -codec copy -ss 00:00:25.5 -t 00:00:33.75 out2.mp4
  • -strict -2 is not required in this case. If you are re-encoding, and no other AAC encoders are available, then ffmpeg will use -codec:a aac which requires -strict -2 (or the alias -strict experimental which I prefer).

  • -codec copy will copy all streams of each type if present. For MP4 that usually just means audio and video, but other containers can have subtitles or even a data stream.

  • You do not need to use -ss if the value is 0.

llogan

Posted 2013-06-12T00:21:36.290

Reputation: 31 929

Exactly what I need! – Alex Smolov – 2013-06-12T11:24:24.323