June 18, 2010

Splitting Videos In Ubuntu

Splitting videos has been a concern over a long time, until recently I found out a simple technique that uses an equally simple command. For this all you have to do is install ffmpeg, either from Synaptic Package Manager or command-line apt-get or aptitude (Ubuntu), or yum, zypper, etc. in case of other distros.

First cd to the directory where you have your video. Then,

varsha@varsha-laptop:~$ ffmpeg -i video_name -ss 00:04:00 -t 00:05:16 "video-part1.avi"


specifies the name of the input file

-ss stands for position in hr:min:sec format where you want the splitting to begin

-t is the duration of the new file

My specification here is to split the video after 4 minutes elapsing from the start time of the original video and having a duration of 5 minutes and 16 seconds.

You can split into multiple parts at the same time.

varsha@varsha-laptop:~$ ffmpeg -i video_name -ss 00:00:10 -t 00:00:30 part1.avi -ss 00:00:35 -t 00:00:30 part2.avi

This creates part1.avi of 30 seconds duration starting from the 10 second of the original video and part2.avi of 30 seconds duration starting from the 35th second of the original video.

[Note: 1. The output file must have a proper recognized format.

2. Check out the manual for more information and details.

varsha@varsha-laptop:~$ man ffmpeg

1 comment: