Author Topic: Howto: Dvd To Avi Using Linux  (Read 875 times)

JerryAttrix

  • Newbie
  • *
  • Posts: 11
    • View Profile
Howto: Dvd To Avi Using Linux
« on: December 11, 2004, 06:56:49 am »
Here's a small Linux script, with documentation, to rip a track from a DVD and convert it to a form suitable for playing on a Zaurus using Kino2.  One of the new 1GB SD cards will hold up to 5 full-length movies converted this way.

I'm posting because I haven't seen it anywhere else on the Forum...

-- GT
Code: [Select]
----------------------------------------------------------------------------------
#!/bin/sh

#######################################################################
# dvd2z
#
# This script is a front end for mencoder to convert a track of a DVD
# into a format suitable for playing on a PDA using Kino2 or equivalent.
# The resulting AVI requires about 80MB/hour using the settings below,
# so a full feature film will fit comfortably onto a 256MB flash card.
# (Terminator 3 needs 188MB)
#
# Some things you may want to alter:
#
# The track number is usually 1 for the main feature of a film.
#
# The video bitrate is set here at 192kbps ("vbitrate=192").  Try
# experimenting with lower values until the quality is unacceptable.
#
# The audio bitrate is 64kbps ("br=64").  Can be reduced but not a lot
# to gain.
#
# Brightness usually has to be boosted for PDA; here it's set to 6
# using "eq=6". Leave this option out for standard brightness.
#
# Frame size is 320:240.  Can be changed but the scaler may not like it
# on replay.
#
# Frame rate can be reduced to 15 ("-ofps 15") to give player less
# work.  Makes a small saving in file size.
#
# Mono audio - a small saving - can be done using "mode=3".
#######################################################################

if [ $# -lt 2 ]
then
    echo "Usage: dvd2z "
    exit
fi

mencoder dvd://$1 -ovc lavc -lavcopts vcodec=mpeg4:vhq:vqmin=2:vqmax=20:vmax_b_frames=2:vbitrate=192:vqcomp=0.6:vpass=1 -vop scale=320:240,eq=6 -ofps 25 -sws 2 -oac mp3lame -lameopts abr:br=64:aq=1:mode=0 -srate 24000 -o "$2".avi

exit
« Last Edit: December 12, 2004, 03:39:52 pm by offroadgeek »
C860 running pdaXrom RC12
SanDisk 1Gb SD card
Buffalo WiFi

ev1l

  • Hero Member
  • *****
  • Posts: 608
    • View Profile
    • http://bbshuffle.blogspot.com/
Howto: Dvd To Avi Using Linux
« Reply #1 on: December 11, 2004, 06:44:46 pm »
You might want to exit with status 1 after your checking ifloop.
The list of swtches is really handy though

JerryAttrix

  • Newbie
  • *
  • Posts: 11
    • View Profile
Howto: Dvd To Avi Using Linux
« Reply #2 on: December 12, 2004, 12:09:47 pm »
Addendum regarding widescreen movies:

To keep the aspect ratio right but still within a 320x240 window, I've found I need a two-pass approach (though I'd welcome suggestions on how to do it in one).  The first thing is to add a suitable border top and bottom to the movie; after that it can be encoded to 320:240.  The aspect ratio of movies varies so some experimentation is needed, but the following worked for The Bourne Identity:

Code: [Select]
----------------------------------------------------------------------------------
mencoder dvd://$1 -chapter 8 -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=4000:vhq -vf expand=0:-160:0:80 -o temp.mpg

mencoder temp.vob -ovc lavc -lavcopts vcodec=mpeg4:vhq:vqmin=2:vqmax=20:vmax_b_frames=2:vbitrate=192:vqcomp=0.6:vpass=1 -vop scale=320:240,eq=6 -ofps 25 -sws 2 -oac mp3lame -lameopts abr:br=64:aq=1:mode=0 -srate 24000 -o "$2".avi

rm -f temp.mpg
----------------------------------------------------------------------------------

In the first command, the DVD is ripped to a high-quality MPEG, with 160 pixels added to its height and the picture offset by 80 pixels to keep it centered.  The second command then writes the result to an MPEG4 AVI.
« Last Edit: December 12, 2004, 03:40:53 pm by offroadgeek »
C860 running pdaXrom RC12
SanDisk 1Gb SD card
Buffalo WiFi

JerryAttrix

  • Newbie
  • *
  • Posts: 11
    • View Profile
Howto: Dvd To Avi Using Linux
« Reply #3 on: December 12, 2004, 12:12:21 pm »
Sorry, I accidentally left in some test code:  the "-chapter 8 is redundant.  Should be:

Code: [Select]
mencoder dvd://$1 -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=4000:vhq -vf expand=0:-160:0:80 -o temp.mpg

mencoder temp.mpg -ovc lavc -lavcopts vcodec=mpeg4:vhq:vqmin=2:vqmax=20:vmax_b_frames=2:vbitrate=192:vqcomp=0.6:vpass=1 -vop scale=320:240,eq=6 -ofps 25 -sws 2 -oac mp3lame -lameopts abr:br=64:aq=1:mode=0 -srate 24000 -o "$2".avi

rm -f temp.mpg
« Last Edit: December 12, 2004, 03:42:22 pm by offroadgeek »
C860 running pdaXrom RC12
SanDisk 1Gb SD card
Buffalo WiFi

JerryAttrix

  • Newbie
  • *
  • Posts: 11
    • View Profile
Howto: Dvd To Avi Using Linux
« Reply #4 on: December 12, 2004, 12:14:10 pm »
Second oops:  The file parameter in the second line should read temp.mpg, not temp.vob.

Must be getting tired...
C860 running pdaXrom RC12
SanDisk 1Gb SD card
Buffalo WiFi

offroadgeek

  • Administrator
  • Hero Member
  • *****
  • Posts: 1419
    • View Profile
    • https://www.oesf.org
Howto: Dvd To Avi Using Linux
« Reply #5 on: December 12, 2004, 03:43:23 pm »
Quote
Second oops:  The file parameter in the second line should read temp.mpg, not temp.vob.

Must be getting tired...
I corrected it
Search the OESF Wiki
C1000 w/Cacko 1.23 beta (from Streamline) / 760 pdaxrom rc9 / 6000L (thanks Santa's elf!) / 5500 - OZ 3.3.5 / SIMpad SL4
1GB, 256mb SanDisk CF / 2x 1GB, 512mb, 256mb, 128mb SanDisk SD
Ambicom WL100C-CF wifi / Socket 56k CF modem / AmbiCom BT2000-CF (x2)
Pocketop keyboard, Piel Frama case (1000 & 5500), PDAir case (760 & 1000)
sip:536093@fwd.pulver.com
| OESF | ELSI | Zaurus User Group | ZaurusThemes |