Custom Search

Saturday, September 01, 2007

More Multimedia

DVD Ripping and Burning Tips

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

lsdvd

to see how many titles and chapters are on the dvd,
and 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 and 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.

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. 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
box, the readme 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 \
nbsp&;nbsp&;nbsp&;nbsp&;-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 ontothe command. As always in the 'nix' world, try

man 1 tcprobe. Yep, READ THE FINE MANUAL! ;)

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 anyway, 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

*UPDATE*
There's a newer version of this article up on my web site
with additional information about how to handle mplex errors.
I think it comes about because of the newer copy protection.
I know when I first added this article to my blog, I wasn't
having those sort of problems with mplex. I could be wrong,
though. Feel free to leave a comment. When you get to the page,
search for "Nasty DVD's". Article is here:

DVD's - Analyze Rip Burn

At this point, you can insert subtitles.
spumux sub.xml < new.mpg > new.vob

Now that you've got your movie ripped and/or shrunk, you
setup the dvd file structure with dvdauthor. First, create
dvd.xml and 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. Let's say you're in /data/dvdfiles.

* 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
coasters and frisbees, for sure. 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 -Z /dev/rcd0c=new.iso

To skip the last 2 steps & burn directly to dvd, do this:

growisofs -dvd-compat -dvd-video -udf -Z /dev/rcd0c \
/data/dvdfiles
(Assuming /dev/rcd0c is your burning device and
/data/dvdfiles is theoutput directory of dvdauthor)

or, for the directory containing AUDIO_TS and VIDEO_TS:

growisofs -dvd-compat -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.

gopher://sdf.lonestar.org/00/users/dancer68/multimedia/
dvdripping.txt.txt
(the double extension's NOT a typo)

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 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. :)

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:

http://www.brandonhutchinson.com/Burning_Video_DVDs_
in_Linux.html

http://www.ericdugas.com/howtos/ripDVDWithMplayer/
ripDVDWithMplayer.php

http://www.dizwell.com/prod/node/47

http://forum.freespire.org/archive/index.php/t-2978.html

http://www.linuxquestions.org/linux/answers/Applications_GUI_
Multimedia/DVD9_to_DVD5_guide

http://wiki.videolan.org/index.php/VLC_command-line_help

http://digg.com/software/How_to_Rip_DVDs_with_VLC

powered by performancing firefox

Labels:

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home