Sunday 29 March 2015

How to quick split an .mp4 file using Linux

I recently wanted to split an .mp4 file in order to use it in one of my presentations. I used to have all the necessary software installed for editing and transcoding video files, but not any more. I was looking for an off-line, quick and reliable solution using only what I had in my disposal. 

Using my Kali distribution, I installed the ffmpeg package. 

apt-get install ffmpeg

After that, everything was easy. Lets assume the name of the video is CyberSecurity.mp4 and its length is 04 minutes and 37 seconds. Also, lets assume that you want the chunk of the video needs to start from the beginning until the 03 minutes and 18 seconds mark.

In order to split this video from the beginning (00:00:00) until the 03 minutes and 18 seconds mark (00:03:18), you will need to run the following command. 

ffmpeg -acodec copy -vcodec copy -ss 0 -t 00:03:18 -i CyberSecurity.mp4 CyberSecurity_new.mp4

Or, you can use the exact "start time" by specifying it: 

ffmpeg -acodec copy -vcodec copy -ss 00:01:00 -t 00:03:18 -i CyberSecurity.mp4 CyberSecurity_new.mp4

In case you need a script to automate the splitting of a video file in equal chunks, you may find this link very useful.

I hope this post was helpful to you as it was for me.

No comments:

Post a Comment