I have a very big movie file, I want to split it in 2. How can I do this?
Asked
Active
Viewed 5,566 times
5
-
1I assume you want to split into a first half and a second half by time (and not, say, left and right halves)? What do you consider “standard unix commands” — you will need a program that understands movie files? – Gilles 'SO- stop being evil' Nov 27 '13 at 23:38
-
Audiovisual media formats are _very_ complicated. Was this text, or HTML at most, it would be doable. Remember this is Unix - the _entire_ reason there are programs specifically to do these things is "do that task (and do it well)". – Luis Machuca Nov 28 '13 at 00:25
-
Do you consider `ffmpeg` a standard UNIX command? 'Cause that'll do it great. – ewhac Nov 28 '13 at 02:06
-
You cannot do that with just using `dd`, without special playing software that you have to give metadata information for all but the first part (try it, with vlc, mplayer). Too little metadata is repeated in the AVI file for that to synchronise. – Zelda Nov 28 '13 at 06:49
1 Answers
13
You could do it like this using ffmpeg. This approach assumes you know the length of the video and want to manually split it at a particular time point. You can use ffmpeg to get the duration like so.
Example
$ ffmpeg -i me.avi |& grep Dura
Duration: 00:01:43.27, start: 0.000000, bitrate: 16330 kb/s
So say we want to split it into 1:00.00 and 43.27, we could do the following 2 commands to do this:
# e.g. from start to 1 min.
$ ./ffmpeg -i me.avi -vcodec copy -acodec copy -t 00:01:00 output1.avi
# e.g. from 1 min. to end
$ ./ffmpeg -i me.avi -vcodec copy -acodec copy -ss 00:01:00 output2.avi
Afterwards we're left with the following results:
$ ls -l me.avi output*
-rw-rw-r-- 1 saml saml 210816000 Nov 27 21:36 me.avi
-rw-rw-r-- 1 saml saml 120361978 Nov 27 21:39 output1.avi
-rw-rw-r-- 1 saml saml 90571034 Nov 27 21:40 output2.avi
And the durations are now:
$ ./ffmpeg -i output1.avi |& grep Dura
Duration: 00:01:00.00, start: 0.000000, bitrate: 16048 kb/s
$ ./ffmpeg -i output2.avi |& grep Dura
Duration: 00:00:43.27, start: 0.000000, bitrate: 16743 kb/s
References
slm
- 363,520
- 117
- 767
- 871
-
Thanks for that well detailed answer. Thanks for linking the reference as well. :) That worked nicely. – Stephane Nov 28 '13 at 12:39