editors: Editing assistance


Previous by date: 18 Jul 2005 16:47:25 -0000 I'd like to help do reviews, Alex Weeks
Next by date: 18 Jul 2005 16:47:25 -0000 what needs edited?, George Harmon
Previous in thread: 18 Jul 2005 16:47:25 -0000 Editing assistance, Mark Komarinski
Next in thread:

Subject: Re: Editing assistance
From: Machtelt Garrels ####@####.####
Date: 18 Jul 2005 16:47:25 -0000
Message-Id: <Pine.LNX.4.44.0507181646310.3931-200000@cobra.xalasys.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Mon, 18 Jul 2005, Mark Komarinski wrote:

> I'm pretty good with spelling and grammar.  Better on the technical reviews.
>
> I can take the DVD Ripping HOWTO for full review if noone else has taken it.

Thank you for volunteering, Mark, and nice to see that you are still
involved with TLDP.  I've attached the document, I guess you have found
your way to the Reviewer's HOWTO along time ago (see
http://tldp.org/HOWTO/LDP-Reviewer-HOWTO/index.html).

Mark & Timo: please contact me if you have any questions.

Thanks for your time,

Tille.


- --
Machtelt Garrels                ####@####.####
Co-editor of LDP Weekly News    http://tldp.org/ldpwn/latest.html

My Penguin, my freedom.         http://tille.xalasys.com

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFC293DsIIUbMXbBA8RAv4rAKCAJc3AjB97oWm1wbFR+2/LSfw/vwCfecnb
sjVTb3Ha+TVZbqLh1HItuwU=
=A8pl
-----END PGP SIGNATURE-----

<!doctype linuxdoc system>

<article>

<title>Linux DVD ripping HOWTO
<author>Timo Benk<url ####@####.####
<date>v1.0, July 2005

<!-- Comment: abstract-->
<abstract>
    <p> This document is a detailed step-by-step guide on ripping DVDs under Linux. This guide 
        describes not how to make SVCD or such formats, its solely purpose is to create a DVD with 
        the best possible quality and with nothing than the movie itself on the DVD, with one or 
        more audio tracks.
    <p> At the end of this howto you will find a handy bash script, which puts all of these steps
        together and which you can use to automate the whole DVD ripping process.

<!-- Comment: Chapter Copyright-->
<sect> Copyright
    <p> Copyright 2005 Timo Benk

    <p> Permission is granted to copy, distribute and/or modify this document under the terms of 
        the GNU Free Documentation License, Version 1.1 or any later version published by the 
        Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with 
        no Back-Cover Texts.

<!-- Comment: Chapter Software-->
<sect> Software
    <p> You will need the following software installed before you start reading any further:
        <itemize>
            <item> lsdvd (part of the AcidRIP project)  
                                    <url url="http://freshmeat.net/projects/acidrip">
            <item> transcode        <url url="http://www.transcoding.org/">
            <item> dvdauthor        <url url="http://dvdauthor.sourceforge.net">
            <item> mkisofs          <url url="http://cdrecord.berlios.de/old/private/mkisofs.html">
            <item> cdrecord-ProDVD  <url url="ftp://ftp.berlios.de/pub/cdrecord/ProDVD/">
        </itemize>

<!-- Comment: Chapter Extracting audio streams and the video stream-->
<sect> Extracting the audio and video streams
    <p> Basically, the whole process looks like the following: extracting the video stream and the
        audio streams, downsize the video stream to fit on DVD, multiplex the audio streams and the
        downsized video stream together again and finally master the DVD.
    <sect1> Locating the audio and video streams
        <p> First of all we need to find the indices of the video stream and the audio streams
            that we intend to put on our final DVD. That will be done with the tool <sl>lsdvd</sl>.
        <p> The command (/dev/sr0 is my DVD drive, you will need to put something usefull there):
        <p> <tt> lsdvd -x /dev/sr0 </tt>
        <p> will produce an output similar to the following listing:
        <p> <code> 
libdvdread: Using libdvdcss version 1.2.5 for DVD access
Disc Title: CDROM
Title: 01, Length: 01:37:58 Chapters: 01, Cells: 01, Audio streams: 02, Subpictures: 00
        VTS: 01, TTN: 01, FPS: 25.00, Format: PAL, Aspect ratio: 16/9, Width: 720, Height: 576, DF: P&amp;S + Letter
        Number of Angles: 1
        Audio: 1, Language: en - English, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 6, AP: 0, Content: Undefined
        Audio: 2, Language: de - Deutsch, Format: ac3, Frequency: 48000, Quantization: drc, Channels: 6, AP: 0, Content: Undefined
        Chapter: 01, Length: 00:37:58, Start Cell: 01
        Cell: 01, Length: 01:37:58

Longest track: 1
</code>
        <p> The information we seek are the audio streams and the index of the longest track on
            the DVD. In this case the DVD consists of two audio streams, one for english and one
            for german language, and the movie track. We keep in mind, that the longest track has 
            the index 1 (the movie itself) and the two audio streams has the indices 0 (english)
            and 1 (german). You may  have observed, that i wrote 0 and 1 for the two audio indices. 
            That is not a typo, you have to decrease the index shown by lsdvd for the audio streams
            by one, because the tool <sl>tcextract</sl> starts counting the audio streams by 0
            (but not the movie streams!)
    <sect1> Get the movie mpeg stream
        <p> We don't want any trailers, comments or other stuff wasting space, and thus quality, of
            our final DVD image. So we need to get the main movie mpeg stream. That is done using
            the following command:
        <p> Create a temporary directory: 
        <p> <tt>mkdir /tmp/dvd</tt>
        <p> Extract the video mpeg stream, including all audio streams (-T 1 is important, it means,
            that the first video track on the DVD will be extracted. You may change that according 
            to your lsdvd output).
        <p> <tt> tccat -i /dev/sr0 -T 1 -P -L > /tmp/dvd/dvd.udf </tt>
    <sect1> Extracting the audio streams
        <p> Extract the english audio stream: 
        <p> <tt> tcextract -i /tmp/dvd/dvd.udf -x ac3 -a 0 > /tmp/dvd/dvd_audio_en.ac3</tt>
        <p> Extract the german audio stream: 
        <p> <tt> tcextract -i /tmp/dvd/dvd.udf -x ac3 -a 1 > /tmp/dvd/dvd_audio_de.ac3</tt>
        <p> Repeat this step for any audio stream you want on your final DVD.
    <sect1> Extracting the video stream
        <p> The video stream may be very big, so be sure, that you have enough place left.
        <p> <tt> tcextract -i /tmp/dvd/dvd.udf -x mpeg2 > /tmp/dvd/dvd_video.m2v</tt>
        <p> We don't need the file dvd.udf anymore, free some disk space and delete it:
        <p> <tt> rm /tmp/dvd/dvd.udf </tt>

<!-- Comment: Chapter Requantisize the video stream-->
    <sect> Requantisizing the video stream
        <p> Normally, the video stream is too big to fit on our DVD. You will need to
            requantisize the video stream. Because we want the best possible quality, we need 
            to calculate the requantisizing factor. That sounds a bit complicated, but 
            the only purpose is to get the factor, by which the video stream needs to be 
            downsized. That is done the following way:
        <sect1> Calculating the requantisation factor
            <p> Let us say, 4350000000 bytes will fit on your DVD.
            <p> Let us assume, your video stream is 5000000000 bytes big.
            <p> The two audio streams are 300000000 bytes big.
            <p> <tt>(2*300000000) + 5000000000 = 5600000000</tt> (too big:-()
            <p> The requantisation factor is calculated the following way:
            <p> <tt> [sizeof(audio streams) + sizeof(video streams)] / sizeof(DVD) </tt>
            <p> <tt> [(2*300000000) + 5000000000] / 4350000000 = 1.287 </tt>
            <p> That means, the requantisizing factor is 1.287
        <sect1> Requantisize the video stream
            <p> The requantisation factor was 1.287, now we can actually requantisize the video
                stream:
            <p> <tt> tcrequant -i /tmp/dvd/dvd_video.m2v -f 1.287 
                     -o /tmp/dvd/dvd_video_requant.m2v </tt>
            <p> <tt> mv /tmp/dvd/dvd_video_requant.m2v /tmp/dvd/dvd_video.m2v </tt>

<!-- Comment: Chapter Multiplexing all pieces together-->
    <sect> Multiplexing all pieces together
        <p> Now the video stream is downsized to fit on the final DVD together with all
            audio streams. The next step is multiplexing the audio streams and the video
            stream into our final mpeg stream. That is done the following way:
        <p> One audio stream: 
        <p> <tt> tcmplex -i /tmp/dvd/dvd_video.m2v 
                         -p /tmp/dvd/dvd_audio_en.ac3 
                         -md -o /tmp/dvd/dvd.vob </tt>
        <p> Two audio streams: 
        <p> <tt> tcmplex -i /tmp/dvd/dvd_video.m2v 
                         -p /tmp/dvd/dvd_audio_en.ac3 
                         -s /tmp/dvd/dvd_audio_de.ac3 -md 
                         -o /tmp/dvd/dvd.vob </tt>
        <p> It is not possible to multiplex more than two audio streams with the tool 
            <sl>tcmplex</sl>. If you have more than two audio streams, you will need some other 
            tool like <sl>mplex</sl> for example. 
            However, not every multiplexing tool will produce a video stream suitable
            for dvdauthor, so you will need to try a bit.
        <p> We don't need the files /tmp/dvd/*.ac3 and /tmp/*.m2v anymore, free some disk space 
            and delete them:
        <p> <tt> rm /tmp/dvd/*.ac3 /tmp/dvd/*.m2v</tt>

<!-- Comment: Chapter Authoring the DVD-->
    <sect> Authoring the DVD
        <p> Now we have an mpeg stream suitable for dvdauthor, which will be used to author the
            final DVD. dvdauthor is quite too complex to be explained in detail here, i will just
            post the config file to be used for our purposes. If you want some more information, 
            read the documentation of the tool dvdauthor.
        <p> The following file dvd.xml will create a DVD with two audio streams. Copy the file
            to the directory /tmp/dvd.
        <p> <code>
&lt;dvdauthor&gt;
    &lt;vmgm /&gt;
    &lt;titleset&gt;
        &lt;titles&gt;
            &lt;audio lang="en" /&gt;
            &lt;audio lang="de" /&gt;
            &lt;pgc&gt;
                &lt;vob file="dvd.vob" chapters="0,240:00" /&gt;
            &lt;/pgc&gt;
        &lt;/titles&gt;
    &lt;/titleset&gt;
&lt;/dvdauthor&gt;
        </code>       
        <p> Whether or not you have more or less than two audio streams, you will need to modify
            the config file accordingly.
        <p> Create a directory named /tmp/dvd/author: 
        <p> <tt> mkdir /tmp/dvd/author </tt>
        <p> The command (mind the brackets!)
        <p> <tt> (cd /tmp/dvd; dvdauthor -o author -x /tmp/dvd/dvd.xml) </tt> 
        <p> will create the DVD data beneath the directory /tmp/dvd/author.
        <p> We don't need the file dvd.vob anymore, free some disk space and delete it:
        <p> <tt> rm /tmp/dvd/dvd.vob </tt>

<!-- Comment: Chapter Mastering the DVD-->
    <sect> Mastering the DVD
        <p> Finally we are able to create the udf ISO image with the command: 
        <p> <tt> mkisofs -dvd-video /tmp/dvd/author > ~/dvd.udf </tt> 
        <p> and burn the DVD: 
        <p> <tt> cdrecord-prodvd ~/dvd.udf </tt>
        <p> We don't need the directory /tmp/dvd anymore, free some disk space and delete it:
        <p> <tt> rm -rf /tmp/dvd </tt>
        <p> That was all the magic:-)

<!-- Comment: Chapter Subtitles-->
    <sect> Subtitles
        <p> I have not found any practicable way to extract and include subtitles. If you
            have any idea how to do that task, email me.

<!-- Comment: Putting all together: dvdrip script-->
    <sect> Putting all together: dvdrip script
        <p> The following script automates all steps described above. It is a handy little tool
            i use myself.
        <p> Usage:
        <p> First of all locate the audio and video streams.
        <p> <tt> lsdvd -x /dev/sr0 | tee dvd.lsdvd </tt>
        <p> Let us assume that track 1 is the longest track, the main movie.
        <p> <tt> tccat -i /dev/sr0 -T 1 -P -L > /tmp/dvd.udf </tt>
        <p> Let us assume that audio stream 0 is in english and audio stream 1 is in german.
        <p> <tt> dvdrip /tmp/dvd.udf 1 0 </tt>
        <p> That's all, have fun :-)
        <p> <code>

#!/bin/sh
#########################################################
##                                                     ##
## dvdrip shell script - part of the DVD ripping HowTo ##
## copyright 2005 Timo Benk ####@####.#### ##
##                                                     ##
## Usage: dvdrip MPEG [DE] EN                          ##
##                                                     ##
#########################################################

set -e

clear

if [[ $# -le 1 ]]
then
    echo Usage: dvdrip MPEG [DE] EN
    exit 0
fi

MPEG="$1"
TMP="/tmp/dvdrip-$MPEG"
LOG=$TMP/log.txt
mkdir -p $TMP

## Audio Data Extraction
if ! test -z "$3"
then
    echo -en "[....] Extracting english audio track from $MPEG\r"
    tcextract -i $MPEG -x ac3 -a $3 &gt; $TMP/dvd_audio_en.ac3 2&gt;&gt; $TMP/log.txt
    echo -e "[DONE]"

    echo -en "[....] Extracting german audio track from $MPEG\r"
    tcextract -i $MPEG -x ac3 -a $2 &gt; $TMP/dvd_audio_de.ac3 2&gt;&gt; $TMP/log.txt
    echo -e "[DONE]"
else
    echo -en "[....] Extracting english audio track from $MPEG\r"
    tcextract -i $MPEG -x ac3 -a $2 &gt; $TMP/dvd_audio_en.ac3 2&gt;&gt; $TMP/log.txt
    echo -e "[DONE]"
fi

## Video Data Extraction
echo -en "[....] Extracting video data from $MPEG\r"
tcextract -i $MPEG -x mpeg2 &gt; $TMP/dvd_video.m2v 2&gt;&gt; $TMP/log.txt
echo -e "[DONE]"

## Requantisizing if necessary
SIZE=$(du -csb $TMP/* | tail -n1 | cut -f1)
MAX="4350000000"
if [[ $MAX -le $SIZE ]]
then
    FACTOR=$(echo $SIZE/$MAX | bc -l | head -c5)
    echo -en "[....] Requantisizing the video data by the factor $FACTOR\r"
    tcrequant -i $TMP/dvd_video.m2v -f $FACTOR -o $TMP/dvd_video_requant.m2v
    mv $TMP/dvd_video_requant.m2v $TMP/dvd_video.m2v
    echo -e "[DONE]"
fi

## Multiplexing all pieces together
if ! test -z "$3"
then
    tcmplex -i $TMP/dvd_video.m2v \
     -p $TMP/dvd_audio_en.ac3     \
     -s $TMP/dvd_audio_de.ac3     \
     -md -o $TMP/dvd.vob
else
    tcmplex -i $TMP/dvd_video.m2v \
     -p $TMP/dvd_audio_en.ac3     \
     -md -o $TMP/dvd.vob
fi
rm -f $TMP/dvd_video.m2v $TMP/dvd_audio_en.ac3 $TMP/dvd_audio_de.ac3

## Authoring the DVD
if ! test -z "$3"
then 
cat &lt;&lt;EOF &gt; $TMP/dvd.xml
&lt;dvdauthor&gt;
    &lt;vmgm /&gt;
    &lt;titleset&gt;
        &lt;titles&gt;
            &lt;audio lang="en" /&gt;
            &lt;audio lang="de" /&gt;
            &lt;pgc&gt;
                &lt;vob file="dvd.vob" chapters="0,240:00" /&gt;
            &lt;/pgc&gt;
        &lt;/titles&gt;
    &lt;/titleset&gt;
&lt;/dvdauthor&gt;
EOF
else
cat &lt;&lt;EOF &gt; $TMP/dvd.xml
&lt;dvdauthor&gt;
    &lt;vmgm /&gt;
    &lt;titleset&gt;
        &lt;titles&gt;
            &lt;audio lang="en" /&gt;
            &lt;pgc&gt;
                &lt;vob file="dvd.vob" chapters="0,240:00" /&gt;
            &lt;/pgc&gt;
        &lt;/titles&gt;
    &lt;/titleset&gt;
&lt;/dvdauthor&gt;
EOF
fi

mkdir -p $TMP/dvd
(cd $TMP; dvdauthor -o dvd -x $TMP/dvd.xml)
rm -f $TMP/dvd.vob

## Mastering the DVD
mkisofs -dvd-video $TMP/dvd &gt; ${MPEG%.*}.udf
rm -rf $TMP


    </code>

<!-- Comment: Todo-->
    <sect> Todo or how you can help me
        <p> I am always open for any ideas you may have to offer for me. In particular, the
            following things are very important:
        <itemize>
            <item> If you find something, that is not well described or hard to understand,
                   ask me and i will correct that part, so long i can follow your criticism.
            <item> Any bug reports regarding this document and the script are also welcome.
            <item> Until now, i have not found any practicable way to extract subtitles and include
                   them in the final DVD.
            <item> And last but not least, i am also very happy if you find this howto usefull
                   and if you mail me your success story:-)
        </itemize>
        <p> Contact me @ Timo Benk <url ####@####.####

</article>





Previous by date: 18 Jul 2005 16:47:25 -0000 I'd like to help do reviews, Alex Weeks
Next by date: 18 Jul 2005 16:47:25 -0000 what needs edited?, George Harmon
Previous in thread: 18 Jul 2005 16:47:25 -0000 Editing assistance, Mark Komarinski
Next in thread:


  ©The Linux Documentation Project, 2014. Listserver maintained by dr Serge Victor on ibiblio.org servers. See current spam statz.