Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 5 down vote accepted

FFmpeg will do this for you.

Your command might look something like this:

Code: ffmpeg -i input.mpg -ss 00:00:10 -t 00:00:30 out1.mpg -ss is the start point in hh:mm:ss from the beginning of your video file

-t is the length of time in hh:mm:ss of your new segment.

So, in the above example, you're starting 10 seconds in from the beginning of the original file and ending 30 seconds later.

If you want to create multiple parts in one pass then the following should work:

Code: ffmpeg -i input.mpg -ss 00:00:10 -t 00:00:30 out1.mpg -ss 00:00:35 -t 00:00:30 out2.mpg In this example, the first segment is the same as the first example, but you're also creating a second file starting at 35 seconds in and being 30 seconds long.


share|improve this answer
yeah ffmpeg has proven more stable for me than mencoder for splitting streams. Note also that if you make every frame an i-frame, you can split quite precisely: ref: here is also a long list here:… – rogerdpack Dec 3 '10 at 7:15

I once hacked this together for getting video of a DVD-RAM:

#! /usr/bin/ruby -w

a = [0, 0x37f9800, 0xf3e1800]

filename = "input.vob"

a.each_with_index{|seq_start, i|
  if seq_start % 1024 != 0 then
    puts "Error: Blocksize doesn't match 1024"

  seq_end = a[i+1]

  if seq_end then
    puts "dd if=#{filename} of=chapter#{i+1}.mpeg bs=1024 skip=#{seq_start/1024} count=#{(seq_end - seq_start)/1024}"
    puts "dd if=#{filename} of=chapter#{i+1}.mpeg bs=1024 skip=#{seq_start/1024}"

The a variable takes the position values where the jump occurs and then just uses dd to slice the file into pieces at those positions. The result are then separate mpeg files for every chapter, as the jump occurred whenever the recording was stopped and restarted. The resulting mpeg files where jump free and could then be processed as usual.

The script itself actually doesn't call dd, it just outputs the dd commands needed to slice the file into pieces.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .