Split, cut, or sample a video file on the command line

Linux
Author

Vinh Nguyen

Published

February 26, 2011

There are many reasons to cut or split a video file. For example, one may want to cut a long video into multiple parts to upload to YouTube. I first ran into this and this, which suggests:

ffmpeg -ss 00:00:00 -t 00:01:00 -vcodec copy -acodec copy -i in.avi out.avi
## -ss: start position
## -t: end position
## can re-encode with other codecs

However, for some reason my out file is almost as large as my in file, even though I'm only sampling 1 minute out of the 2 hour segment. This lead me to the mencoder solution:

mencoder -ss 00:00:00 -endpos 00:00:01 -ovc copy -oac copy in.avi -o out.avi

The file size of my out file is more reasonable, and the speed is incredibly fast since I am not re-encoding.