puflogh300X74.gif

Polarwave's OpenBSD
Tips and Tricks for Newbies

| DVD's - Analyze Rip Burn |

| Home | Tips and Tricks | Links | News Feeds | Fun | Contact | Blog (Opens in New Page) |


DVD's

Analyzing DVD Content

I usually use 1 of 2 methods for finding out what's on a dvd. First, I run:

lsdvd
to see how many titles & chapters are on the dvd, & I look for the main title. More
often than not, it's the first one, but not always. Good example was one I ran across
that had five 24 minute episodes and then one large file with all 5 in it. When I played
the dvd with mplayer, I saw on the menu you could choose each individual episode, or
you could choose the menu listing 'play all'. The combined file was too large for a
single-layer dvd, but I could rip each individual episode and put 3 on one dvd & the
other 2 on a 2nd dvd. Here's how I did it, starting with episode 1:
mplayer dvd://1 -dumpaudio -dumpfile episode1.ac3
mplayer dvd://1 -dumpvideo -dumpfile episode1.m2v
mplex -f 8 -o episode1.vob episode1.ac3 episode1.m2v
So, in the above scenario, title one was just one episode, not the main movie file
with all the episodes in it.

==================================================
Addendum
Mon Apr 5 21:16:18 CDT 2010

Got an email from someone trying to follow the instructions on this page wanting
to know why the -f switch wouldn't work for him while using mplex(1). Turns out
the mplex(1) written about on this page is part of the mjpegtools port. So, if you
installed the indiviual port from /usr/ports/graphics/mplex or the package,
uninstall it and install mjpegtools.
==================================================

The other program I use to check the dvd is streamanalyze, part of the streamdvd
package, which includes lsdvd, at least in the OpenBSD version of it. Do this:
streamanalyze -i /dev/rcd0c -t 1 (assuming title 1 is the main title)
That'll show you what's in title 1. The file formats look like:

Videostream id's always start with '0xen' where n is the track number. In most cases
a video dvd contains only one video stream '0xe0' but multiangle videos might contain
more video streams.

Audiostream id's always start with '0x8n' where n is the track number. Most video
dvd's contain multiple audiostreams in different languages, director comments, etc.
There's a special case for mpeg audiostreams that are pretty rare for find. If you
have a dvd containing mpeg audiostreams and want to select one of them, use '0xcn'
as an identifier where n is the tracknumber (also special, counting starts from 1).

Subpicturestream id's always start with '0x2n' where n is the track number. Most video
DVDs contain multiple subpicture streams in different languages.

The above info on streamanalyze and streamdvd can be found in readme files installed
with the programs. On my OpenBSD 4.1 box, the readme's are in:
/usr/local/share/doc/streamdvd/README.streamanalyze
/usr/local/share/doc/streamdvd/README.streamdvd
* NOTE *
You can use streamdvd to rip and shrink a dvd movie, but be forewarned, YMMV! I did
okay with it on smaller movies, and even on shrinking some larger ones, but when it
came to extracting particular streams rather than just everything, the program choked
up on me more often than not. It may have something to do with the way it interfaces
with dvdauthor:
dvdauthor -t -o /path/to/save -f 'streamdvd -i /dev/rcd0c -t 1 \
     -s 0xe0,0x80,0x20 -c 1-9 |'
That's a good example. It's trying to get title 1, the main video, the first audio, and
the first subtitle, chapters 1 through 9. That's what the docs say. But, it always seems
to run into problems. That's why I turned to mplayer in the first place.

Before leaving this section, tcprobe deserves mention. It's part of transcode but can be
used independently for medium and print information. The command
tcprobe -i foo.avi
will print interesting information about the avi file itself and its video audio content.
It has some interesting switches you can tack onto the command. As always you should try
man 1 tcprobe. Yep, READ THE FINE MANUAL! ;)

Ripping DVD's with Mplayer

Before doing any ripping, if you see the main title is really a whopper, like 8GB or so,
you can rip the movie in 2 parts with mplayer. Let's say lsdvd reports there are 24 chapters
in the main title. To split the dvd:
mplayer dvd://1 -chapter 1-12 -dumpstream -dumpfile movie1st.vob
mplayer dvd://1 -chapter 13-24 -dumpstream -dumpfile movie2nd.vob
But, if you see your movie will fit on a single-layer dvd, or that it looks close, just do this:
mplayer dvd://# -dumpstream -dumpfile movie.vob
To play the movie with english subtitles, do this:
mplayer -sid 0 movie.vob
If your movie won't fit on a single-layer dvd, but it doesn't look too awfully big, after you've
ripped it, do the following:

Extract audio:
tcextract -i movie.vob -t vob -x ac3 -a 0 > audio.ac3
Extract video:
tcextract -i movie.vob -t vob -x mpeg2 > movie.m2v
If you need subtitles use spububmux from dvdauthor and ifo_dump from libdvdread-utils.
Check for color palette:
ifo_dump /dev/rcd0c 1 |grep Color |sed 's/Color ..: 00//' > palette.yuv

Generate picture PNG in format 4.12
spuunmux -s 1 -p palette.yuv movie.vob
This command generates PNG files and command file sub.xml
Calculate the exact shrinkage factor with this formula:
requant_factor = (video_size / (4700000000 - audio_size)) * 1.04
* NOTE: This worked perfectly for me first time out. YMMV!
Now use the factor derived from the formula above to shrink the video:
tcrequant -i movie.m2v -o new.m2v -f (shrinkage factor)
* NOTE *
From everything I've read on shrinking, you shouldn't go larger than a 1.5 factor.
It degrades the quality too much. If after running the formula above you find the
factor exceeds 1.5, you should probably split the movie.

Now recombine new.m2v with the audio file audio.ac3:
mplex -f 8 -o new.mpg new.m2v audio.ac3
At this point, you can insert subtitles.
spumux sub.xml < new.mpg > new.vob

Nasty DVD's

* NOTE *: The Nasty DVD's section has been added since I first put this information
together on my Blogger Account. I had never run into the following problem before until
recently. So, I've included this section too YMMV with this. I didn't have to do all the
'catting' of files together. After the following procedures, I wound up with only 2 blank
mpg's and the one good one. You, on the other hand, may wind up with several good ones
that will have to be combined or 'catted' together. Okay, on to the business at hand.

Usually most users end up getting frustrated at the above error and start Googling their
way into insanity. Have faith however, the following should solve your problem! Although
it isn't pretty, it will backup even the most stubborn DVDs out there.

Output to Multiple Files

Let's fix the above command so it will crank out several files. You might want to do this
in a new directory as it may poop out many mpgs.

mplex -f 8 -o final_output%d.mpg output_shrunk.m2v output.ac3
{i} The %d here tells mplex that it is now free to crank out as many split files as required
by the video file.

Remove Blank MPG's

Here is where the nightmare starts. Once mplex is finished, you will need to browse
through all of your final_output#.mpg files. Usually there are many that are very
small blank short mpgs. Play them in a media player to confirm. What you are looking
for is your primary title files. Make a note of them all, and discard the rest of the files.

{i} Because we are now dealing with a tricky (and probably copy protected) DVD, our
audio will be completely out of sync. Ignore this for now.

Strip the Video Stream AGAIN

So now we have who knows how many mpgs containing our copy protected / tricky / poorly
made DVD. Because mplex tried to sync the sound to the tricky sections that are now
gone, we will need to rip our lovely main title out of the mix again. To do this,
simply re-issue the mplayer command to strip the video. You will need to strip each
video stream into individual m2v files. {i} If someone knows how to clean this step
up, please adjust the wiki accordingly.

mplayer -dumpvideo -dumpfile <Output_Filename_#.m2v> <Input_Filename#.mpg>
Now we should have a series of m2v files that contain only our primary title without
all the garbage chunks that were causing grief before. You can now remove all of the
older mpg files. You will only require the newest m2v files created above along with
the original sound track.

Concatenate the Video Stream

Let's make the multiple files one again so we can sync up our singular sound file
to the new title:

cat file1.m2v file2.m2v file3.m2v > final_title.m2v
{i} The above assumes you re-named your output m2v files file1, file2, and file3.
Put whatever your files are here in order.

Combine the Video with Audio AGAIN

Same as our earlier step:
mplex -f 8 -o final_output%d.mpg final_title.m2v output.ac3
Phew! That was a lot of work eh? To summarize what we have done:

Now that you've got your movie ripped and or shrunk, you setup the dvd file structure
with dvdauthor. First, create dvd.xml:

⟨Name it whatever you want. Just be sure to have an .xml extension)⟩

<dvdauthor>
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="new.vob" />
</pgc>
</titles>
</titleset>
</dvdauthor>
Pass the xml file to dvdauthor for authoring:
dvdauthor -o /path/you/saved/to -x dvd.xml
Dvdauthor creates 2 subdirectories below where you're at, AUDIO_TS & VIDEO_TS.

Burning Your DVD's

* NOTE *
I don't know if I can stress the value of dvd rewritables enough! Catch some on sale and
get them. They'll save you making coasters and frisbees. I got some half-priced recently
by watching the Sunday ads. Of course, you can take your changes on eBay. I haven't run
into hardly any problems in three years. 'X' Those are crossed fingers. ;) Anyway, here's
some info on rewritables:

To blank a dvd-rw that already has been written to, and really wipe everything off of it, do:

dvd+rw-format -blank=full /dev/rcd0c
That does a full blanking. This will take about one hour on 1x media. A fast blanking can be done by:
dvd+rw-format -blank /dev/rcd0c
On to the burning.

To create an image to burn, do this:
mkisofs -dvd-video -udf -o new.iso /data/dvdfiles/
To burn the image, do this:
growisofs -speed=2 -Z /dev/rcd0c=new.iso
To skip the last 2 steps & burn directly to dvd, do this:
growisofs -dvd-compat -dvd-video -speed=2 -udf -Z /dev/rcd0c /data/dvdfiles
(Assuming /dev/rcd0c is your burning device & /data/dvdfiles is the output
directory of dvdauthor)
or, for the directory containing AUDIO_TS and VIDEO_TS:
growisofs -dvd-compat -speed=2 -Z /dev/rcd0c -dvd-video .
(and don't forget the . on the end)
* NOTE on burning devices *
On other 'nix' type systems, your burning device might be and probably is something other
than /dev/rcd0c but I'm writing as an OpenBSD user, and that's what my device is. Also,
I've added the speed parameter to all the burning commands. I know what the man pages
say about it, but once again, YMMV depending on your brand of dvd writer. I've tried
speed=3 and it totally screwed the dvd. Mine works best at speed=2 which comes out to
burning at 8x. And, when I burn to rewritables, the system defaults to 2x, very slow, but
very reliable. Like I said before, you just can't stress how nice it is to have some rewritables
around, that is, unless you like to collect frisbees, coasters, etc.

VLC

A most amazing video program, to say the least. I recently found out you can rip a dvd with
it. I first started reading about it at:

How to Rip DVDs with VLC

There's also a huge amount of info on using the command line with it at:

VLC command-line help

As a side note, here's an alternative to streaming with vlc using nc or netcat:

On your streaming client, type this first.

$ nc -l 1234 | mplayer -cache 8192 -
Then walk to your streaming server (or call your buddy on the other end) and push the file
down the network's throat. Filename is just an example:
$ cat Aerosmith-Amazing.mpg | nc 192.168.1.5 1234
(If the streaming client IP is 192.168.1.5...
That is all. It works. Really cool stuff! If you're on the client end, you could still use
vlc to do the same thing I just outlined with vlc to save the stream.

Some links that helped me:

BackupDVD - Really Good One!
Burning Video DVD's in Linux
Rip Individual DVD Chapters With Mplayer
Video for all, Copying, ripping, decoding DVD How?
DVD9 to DVD5 guide
VLC command-line help
How to Rip DVDs with VLC

Back to Tips and Tricks
Home

Delicious Bookmark this on Delicious

No affiliation between this site and the OpenBSD project exists or is implied.

valid-html401.png