Cutting/splitting video files

So we have a video file that needs to be truncated, split etc. without re-encoding… The main contenders are ffmpeg, mplayer/mencoder and VLC.

# ffmpeg - uses start time, then duration
ffmpeg -ss 00:12:34.5 -t 00:00:59.5 -acodec copy -vcodec copy -i input.mpg output.mpg

# mencoder - uses start time / stop time.
mencoder -ss 00:12:34.5 -endpos 00:13:35 -oac copy -ovc copy input.mpg -o output.mpg

For VLC, use stream exporting wizard, select a file/playlist item, then enable partial extract. The values to enter are in seconds, this is poorly documented, and there is no error checking on this dialog. An extract from 12.34.5 to 13:35 will be 754.5 to 814. Next step, leave the transcoding options unticked as this will default to “stream copy”, i.e. no re-encoding, next select a container format, and press Finish.

MythTV users: I have found mencoder 4.2.1 will not cope well with MPEG-TS recordings, esp. if there is any corruption, it will simply loop trying to find the start position. FFMPEG 0.7.11 and VLC 2.0.1 work correctly with MythTV files.

Leave a comment

Your email address will not be published.