Split MPEG video from command line?

Posted by Tim on Super User See other posts from Super User or by Tim
Published on 2009-08-28T04:29:57Z Indexed on 2010/03/21 20:11 UTC
Read the original article Hit count: 347

I have a homemade DVD that I'm effectively trying to insert chapters into and rearrange - the original author burned it as one long chapter, and I'd like to rip it into smaller pieces and re-encode it into a new DVD. I ripped the DVD with the following command:

mplayer dvd:// -dvd-device /dev/sr2 -dumpstream -dumpfile raw.vob

I'm running Gentoo Linux with mplayer version 1.0-rc2_p20090731 (the latest available in Portage).

I have a list of times that the chapters are supposed to span (for example 30:11-33:25), so my first thought was to rip the entire DVD and use mpgtx to cut out certain pieces of the file. My issue is that running mpgtx -i on the file reports quite a few timestamp jumps:

Time stamps jumped from 59.753789 to 0.001622 at position 1d29800
Time stamps jumped from 204963823030450.343750 to 31.165900 at position 2d4f800
Time stamps jumped from 60.077878 to 0.001622 at position 43cc000 
Time stamps jumped from 60.024233 to 0.001622 at position 65c5000
Time stamps jumped from 204963823068631.718750 to 52.549244 at position 7fd1000

I've tried to fix the indexes using:

mencoder raw.vob -oac copy -ovc copy -forceidx -o fixed.vob -of mpeg

But mpgtx will still report timestamp issues. My immediate question: is there a way to take the ripped movie I have and correct its timestamps so I can cut it with mpgtx? If I can get that one issue out of the way, building the rest of the DVD will be smooth sailing.

If it's not possible to fix the timestamps on this file: is there a better way to rip small chunks of the DVD into separate files for recompilation later? I'd very much like this to be done on Linux, and it'd be even better if I could script it somehow (feed in a list of start and end positions, or start times and durations, and get out a series of ripped files). If need be, I also have a Mac OS X machine available, but no Windows.

Edit: I wound up finding another solution involving HandBrake and ffmpeg (with help from this question), but the question stands.

Edit again: Turns out my other solution didn't quite work - the audio desynchronized by about five seconds, in about half of my cut mpgs - so I'm back to square one. Anyone?

© Super User or respective owner

Related posts about dvd

Related posts about ripping