LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion
User Name
Password
LinuxAnswers Discussion This forum is to discuss articles posted to LinuxAnswers.

Notices


Reply
  Search this Thread
Old 03-04-2005, 12:18 AM   #106
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48

I have possibly a better idea for reading in the desired audio tracks. How about instead of all this:

Code:
echo " "
echo -n "How many audio tracks do you want to rip? (Default is 1) >"

read NUM_AUD_TRACKS

# We must rip at least one track; ensure it's at least 1
[[ $NUM_AUD_TRACKS -eq 0 ]] && NUM_AUD_TRACKS=1

# Let user know how many will be ripped
echo " "
echo "Ripping $NUM_AUD_TRACKS audio tracks from disc"
echo " "

# Read in the desired AID code for each track
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
  # Need to devise a way to do this step in -handsfree mode;
  # How do we choose AID codes automatically?
  echo -n "Enter the audio ID (AID) code you wish to rip (ex. 128) >"
  read -e TRACK_AID[ $CUR_TRACK ]
  AUD_FILE[ $CUR_TRACK ]=$( echo "lang$CUR_TRACK.ac3" )
done
We do something simpler, like this:

Code:
mplayer -nojoystick -nortc -nolirc -dvd-device /dev/dvd dvd://$title -vo null -ao null -frames 0 -v | grep aid

echo -n "Enter the audio ID (AID) codes of the tracks you wish to rip, separated by spaces (e.g. 1 2 3) >"
read -a TRACK_AID

NUM_AUD_TRACKS=${#TRACK_AID[@]}
CUR_TRACK=0
while [[ "$CUR_TRACK" -lt "$NUM_AUD_TRACKS" ]]; do
  AUD_FILE[$CUR_TRACK]=$( echo "lang$CUR_TRACK.ac3" )
  (( CUR_TRACK++ ))
done
This will put all the selected track numbers in an array automatically, and not bother with the extra step of asking how many tracks to rip. Don't know if it will solve the problem, but it would simplify things a bit. Try this code, and let me know if it works! (You may also need to add (( CUR_TRACK++ )) to the other loops that use it; I forgot this in the earlier version).

Last edited by wapcaplet; 03-04-2005 at 12:21 AM.
 
Old 03-04-2005, 01:08 AM   #107
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
Testing it right now and it seems to work quite well. You are my code hero you know. This a great learning curve for me. Hahahaha!

Quite efficient. It does eliminate extra steps and bring down the code to fewer lines and added functionnality.


I just modified the message formating from :

Quote:
"Enter the audio ID (AID) codes of the tracks you wish to rip, separated by spaces (e.g. 1 2 3) >"
To:

Quote:
"Enter the audio ID (AID) codes of the tracks you wish to rip, separated by spaces (e.g. 128 129 etc...) >"
I was confused at first myself as to enter the audio track number (0 or 1 or 2) or the AID numbers so this way there can be no confusion for the user.

I also added two progress messages ("Now ripping the audio stream(s)", etc...) for the user. That is one of the complaints I sometimes have. The progress was not always well indicated. Here they are:

Quote:
# Inform user of what's about to happen
echo "================================================= "
echo "The DVD will now be ripped, it may take some time"
echo "================================================= "
echo " "

# Keep the user informed on the progress
echo "========================================= "
echo "Now ripping the audio stream(s)"
echo "========================================= "
echo " "

# Rip each audio track
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
mplayer -nojoystick -nortc -nolirc -dvd-device $dvd dvd://$title -dumpaudio -aid ${TRACK_AID[ $CUR_TRACK ]} -dumpfile $loc/$disktitle/${AUD_FILE[ $CUR_TRACK ]}
(( CUR_TRACK++ ))
done

# Moving on to video...
echo "========================================= "
echo "Now ripping the video stream"
echo "========================================= "
echo " "

# Rip the video track
mplayer -nojoystick -nortc -nolirc -dvd-device $dvd dvd://$title \
-dumpvideo -dumpfile $loc/$disktitle/output.m2v


Let you know when I am done testing it out.
 
Old 03-04-2005, 09:24 AM   #108
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
lol, ok so which one are we testing? I dunno which one to copy...would like to test it too.

Or just paste the "fixed" one again, thanks.

BTW guys, if you're looking for a good UI design for dvrequant, look at this:

http://pingwing.xs4all.nl/view.php/page/DVDRipOMatic

It would be nice to have something in tovid that just rips a dvd and encodes it to a divx/xvid, etc. The above does that well, but it doesn't support NTSC dvd's (or so, it says. I am ripping one anyways to see what happens). Ofcourse, the above uses transcode instead (hrm, looks like its using mplayer and mencoder as well...)

And thats the first time i have used a kommander app, and it does look pretty good. Didn't know how to use a kommander app either, but you just download the app, and run '$ kmdr-executor DVDRipOMatic.kmdr'.

The author also has many other interesting DV related projects worth checking:

http://pingwing.xs4all.nl/view.php/page/KommanderApps

/edit: oops, looks like the only ones available for now are dvdripomatic and KDE DVD Authoring Wizard. The others are not released yet, so it says.

/edit2: Wow, you guys have to try out the KDE DVD Authoring Wizard, its very nicely done.

Last edited by sk545; 03-04-2005 at 10:45 AM.
 
Old 03-04-2005, 10:44 AM   #109
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
You had forgotten to enter the variable name for the audio file in the requantization factor formula. It made the script skip over it after ripping.

Fixed it:

Quote:
echo " "
echo "================================== "
echo "Calculating best requant factor..."
echo "================================== "
echo "==========================================="
echo "The closer to 1.00 the factor is the better"
echo "=========================================== "
echo " "

cd $loc/$disktitle

vsize=`du -b output.m2v | cut -c 1-10` # video_size
audioa=`du -b ${TRACK_AID[ $CUR_TRACK ]} | cut -c 1-9` # audio_size for track #1

After that my test run was successful ans here is the newcode (0.186a):

*****Don't forget to rename your config file to ".dvrequant_config"

Code:
#! /bin/bash

# DVrequant script   

# Will rip a DVD-9 disc with the  title and audio of your
# choice and requantize it to fit on a DVD-R 4.7
# Steel_J  2005-03-04

# Additional code for chaptering and error checking from Eric Pierce (WapCaplet) 2005-03-04
# Set to read from config file and work hands free by Daniel Patterson (KillFire) 2005-02-24
# Without these guys this script would'nt have been the same.

# This software is licensed under GPL.

# Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd / K3B

#===========================================================================

# DEFAULTS AND FUNCTION DEFINITIONS
# Configuration file
CONFIG_FILE=~/.dvrequant_config
# Hands-free operation? (empty == no)
NOHANDS=""

# Take an integer number of seconds and format it as hours:minutes:seconds
# Echoes result to stdout, so in order to use the output as a "return value",
# call the function like this:
#   RETURN_VALUE=$( format_time $NUM_SECONDS )
format_time ()
{
  let "HMS_HOURS=$1 / 3600"
  let "HMS_MINS=( $1 % 3600 ) / 60"
  let "HMS_SECS=$1 % 3600 % 60"

  [[ $HMS_HOURS -lt 10 ]] && HMS_HOURS="0${HMS_HOURS}"
  [[ $HMS_MINS -lt 10 ]] && HMS_MINS="0${HMS_MINS}"
  [[ $HMS_SECS -lt 10 ]] && HMS_SECS="0${HMS_SECS}"

  echo "${HMS_HOURS}:${HMS_MINS}:${HMS_SECS}"
}

# Take a string containing a time (like "02:15:25.3") and
# format it as an integer number of seconds. Fractional seconds
# are truncated. Result is echoed to stdout, so to use the output
# as a "return value", call the function like this:
#   RETURN_VALUE=$( unformat_time $TIME_STRING )
unformat_time ()
{
  HMS_HOURS=$( echo $1 | sed -r -e 's/0?([0-9]+):0?([0-9]+):0?([0-9]+)(\.[0-9])?/\1/' )
  HMS_MINS=$( echo $1 | sed -r -e 's/0?([0-9]+):0?([0-9]+):0?([0-9]+)(\.[0-9])?/\2/' )
  HMS_SECS=$( echo $1 | sed -r -e 's/0?([0-9]+):0?([0-9]+):0?([0-9]+)(\.[0-9])?/\3/' )
  let "TOT_SECONDS=$HMS_HOURS * 3600 + $HMS_MINS * 60 + $HMS_SECS"
  echo $TOT_SECONDS
}

# Retrieve the chapter breaks from the specified track on the DVD.
# Echoes a string to stdout with a list of chapter-start times
# (i.e., "0, 1:53, 15:26, 1:23:15" etc.)
# To use output as a "return value", call the function like this:
#   CHAPTER_START_TIMES=$( get_chapters $TITLE )
get_chapters ()
{
  CH_LIST=$( lsdvd -c -t $1 2>&1 | grep "Chapter:" | \
      sed -r -e 's/^.* Length: ([^,]+).*$/\1/' )
  
  # Assemble the list
  echo -n "0"
  TOTAL_SECS=0
  for CUR_CHAP in $CH_LIST; do
    CUR_SECS=$( unformat_time $CUR_CHAP )
    # Don't insert markers for 0-second chapters
    if [[ $CUR_SECS -gt 0 ]]; then
      let "TOTAL_SECS=$TOTAL_SECS + $CUR_SECS"
      CUR_TIME=$( format_time $TOTAL_SECS )
      echo -n ",$CUR_TIME"
    fi
  done
}

# Presentation

clear
version=0.186a

echo -e "===================="
echo -e "* DVRequant v${version} *"
echo -e "===================="

echo "Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs)  / lsdvd "
echo " "
echo "growisofs or K3B are optional but recommended"
echo " "

#============================================================================

# checking for needed software

if ! which mplayer >/dev/null ; then
  echo " "
  echo "mplayer is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if ! which transcode >/dev/null ; then
  echo " " 
  echo "transcode is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if ! which mpeg2enc >/dev/null ; then
  echo " "
  echo "mjpegtools is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if ! which dvdauthor >/dev/null ; then
  echo " "
  echo "dvdauthor is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if ! which mkisofs >/dev/null ; then
  echo " "
  echo "cdrecord (mkisofs) is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if ! which lsdvd >/dev/null ; then
  echo " "
  echo "lsdvd is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if ! which /usr/*/libdvdcss.so.2* >/dev/null ; then
  echo " "
  echo "*************************************************************** "
  echo "libdvdcss is not detected, you need it to complete the process.";
  echo "*************************************************************** "
  echo " "
  echo "******************************************************************************** "
  echo "The script will keep going but may exit with errors when trying to read the DVD. "
  echo "******************************************************************************** "
  echo " "
 fi

  #==========================================================================

# Read command-line arguments
while [[ ${1:0:1} == "-" ]]; do
  if [[ $1 == "-nohands" ]]; then NOHANDS="y"
  # More arguments can go here someday
  fi
  # Get next argument
  shift
done

# Read config file

echo "==============================="
echo "Reading from the config file..."
echo "==============================="
echo " "

# If config file doesn't exist, create it
if [[ ! -e "$CONFIG_FILE" ]]; then
	echo "DVD /dev/dvd" > "$CONFIG_FILE"
  echo "LOC /home/$USER" >> "$CONFIG_FILE"
	#echo "LOC `echo $HOME`/video" >> "$CONFIG_FILE"
fi

loc=$( eval "echo `cat "$CONFIG_FILE" | grep LOC | cut -c 5-60`" )

if [[ ! -d $loc ]]; then
	mkdir $loc
fi

dvd=`cat $CONFIG_FILE | grep DVD | cut -c 5-40`

#===========================================================================

# Create project folder and choose preferences

echo "A work folder will now be created with the name of the DVD movie"
echo "in $loc. If you would like to use a different work folder, edit"
echo "$CONFIG_FILE and change the LOC line."
echo " "

disktitle=`lsdvd $dvd -q | grep Disc | cut -c 13-50`

if [[ ! -d $disktitle ]]; then
  mkdir $loc/$disktitle
else
  echo "Directory $loc/$disktitle already exists. Continuing."
fi

    
#==========================================================================

# video stream sub-section

# choose the longest title
      
title=`lsdvd $dvd | grep Longest | cut -c 16-17` 

length=`lsdvd $dvd -q -t $title | grep Length: | cut -c 20-40`
echo " "

echo "***** The longest title is -$title- and is -$length- long.*****"
echo " "

# If doing hands-free operation, assume "y" and continue
if [[ $NOHANDS == "y" ]]; then
  want="y"
  echo "Hands-free operation. This track will be used automatically."
# Otherwise, prompt for whether to continue
else
  echo "(Hint: If you don't want to be prompted for anything,"
  echo "run this script with the -nohands option.)"
  echo "If this is the video track you want, you can continue"
  echo "automatically. If not, you can choose a different track"
  echo "to rip. Use this track? (y or n) (default is -y-)>"
fi

read want
 
# If not what user wanted, prompt for video title
if [[ "$want" == "n" || $want == "N" ]]; then
	     
  # Ask the user which video title he wants to rip from DVD
  echo " "
  echo "========================================== "
  echo "These are all the video titles on the disc"
  echo "========================================== "
  echo " "
    
  lsdvd  -v $dvd | more

  echo " "
  echo -n "What title do you want to rip? (ex. 1, 2 or 3) >"
       
  read -e title
     
  echo " "
  echo "===================== "
  echo "You picked title >#" $title
  echo "===================== "
  lsdvd -t $title | more

# If it's what the user wanted, skip title selection
else
  echo " Moving on to picking an audio track "
  echo " "
fi    
       
      
#audio stream sub-section
 
echo " "
echo "============================================= "
echo "These are all the audio tracks for this title"
echo "============================================= "
echo " "

mplayer -nojoystick -nortc -nolirc -dvd-device /dev/dvd dvd://$title -vo null -ao null -frames 0 -v | grep aid

CHAPTER_START_TIMES=$( get_chapters $title )

echo " "
echo -n "Enter the audio ID (AID) codes of the tracks you wish to rip, separated by spaces (e.g. 128 129 etc...) >"

read -a TRACK_AID

NUM_AUD_TRACKS=${#TRACK_AID[@]}
CUR_TRACK=0
while [[ "$CUR_TRACK" -lt "$NUM_AUD_TRACKS" ]]; do
  AUD_FILE[$CUR_TRACK]=$( echo "lang$CUR_TRACK.ac3" )
  (( CUR_TRACK++ ))
done


# Inform user of what's about to happen
echo " "
echo "================================================= "
echo "The DVD will now be ripped, it may take some time"
echo "================================================= "
echo " "

# Keep the user  informed on the progress
echo "=============================== "
echo "Now ripping the audio stream(s)"
echo "=============================== "
echo " "

# Rip each audio track
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
	mplayer -nojoystick -nortc -nolirc -dvd-device $dvd dvd://$title -dumpaudio -aid ${TRACK_AID[ $CUR_TRACK ]} -dumpfile $loc/$disktitle/${AUD_FILE[ $CUR_TRACK ]}
	 (( CUR_TRACK++ ))
done

# Moving on to video...
echo " "
echo "============================ "
echo "Now ripping the video stream"
echo "============================ "
echo " "

# Rip the video track
mplayer -nojoystick -nortc -nolirc -dvd-device $dvd dvd://$title \
  -dumpvideo -dumpfile $loc/$disktitle/output.m2v 

# Calculate requant factor      
#requant_factor = (video_size / (4700000000 - audio_size)) * 1.04

# If you are including more than one audio stream or a subtitle stream, those   
# filesizes must also be subtracted from the maximum dvd image size.
   
echo " "
echo "================================== "
echo "Calculating best requant factor..."
echo "================================== "
echo "==========================================="
echo "The closer to 1.00 the factor is the better"
echo "=========================================== "
echo " "
 
cd $loc/$disktitle
    
vsize=`du -b output.m2v | cut -c 1-10`                                                      # video_size
audioa=`du -b ${TRACK_AID[ $CUR_TRACK ]} | cut -c 1-9`              # audio_size for track #1

# Add up audio sizes for all tracks
CUR_TRACK=0
AUDIO_SIZE=0
while [[ $CUR_TRACK -lt $NUM_AUDIO_TRACKS ]]; do
  AUDIO_SIZE=$(( $AUDIO_SIZE + `du -b ${AUD_FILE[ $CUR_TRACK ]} | cut -c 1-9` ))
   (( CUR_TRACK++ ))
done
                  
dvdlessaudio=$(( 4700000000 - $AUDIO_SIZE ))
division=$(echo "scale=2; $vsize/$dvdlessaudio" | bc)
  
req=$(echo "scale=2; $division*1.05" | bc)     # requant_factor  
			 
echo " " 
echo "====================================== "
echo "Requant factor for this movie is:"  "$req"
echo "====================================== "
echo " "

#echo " "
#echo "====================================== "
#echo "You can eject the DVD now if you want."
#echo "====================================== "
#echo " "
  
#========================================================================    

# Requantize it, if necessary:

if [[ $( echo "$req > 1.00" | bc ) == "1" ]]; then
  echo "========================================= "
  echo "Requantizing (shrinking) the video stream"
  echo "========================================= "
  tcrequant -d2 -i output.m2v -o shrinked.m2v -f $req
  
  # Cleaning....  
  rm output.m2v
  else
  echo "========================================= "
	echo "No requantization necessary. Skipping"
  echo "========================================= "
  mv output.m2v shrinked.m2v
fi

#========================================================================
     
# Remultiplex:

echo " "
echo "====================================== "
echo "Multiplexing audio and video stream(s)"
echo "====================================== "
echo " "
 
# Construct a multiplexing command, listing all the
# language tracks.
MPLEX_CMD="mplex -f 8 -o final.mpg shrinked.m2v"
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
  MPLEX_CMD=$( echo " $MPLEX_CMD ${AUD_FILE[ $CUR_TRACK ]}" )
   (( CUR_TRACK++ ))
done

eval "$MPLEX_CMD"
				    
# Cleaning up
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
  rm ${AUD_FILE[ $CUR_TRACK ]}
   (( CUR_TRACK++ ))
done
rm shrinked.m2v    
   
#========================================================================     
# Re-author it
# This will create a folder named "dv_dvd" and generate inside it
# a dvd structure -- VIDEO_TS and AUDIO_TS

echo " "
echo "========================================= "
echo "Authoring and generating a DVD structure"
echo "========================================= "

# Populate filesystem
dvdauthor  -t  -o  dv_dvd  -c $CHAPTER_START_TIMES final.mpg
	   
# Create IFO files
dvdauthor -o dv_dvd -T 
		    
# Create DVD Video compliant ISO image
mkisofs -dvd-video -udf -V $disktitle -o $disktitle.iso $loc/$disktitle
	       
#========================================================================       
# End messages

echo " "
echo "==============================================================================="
echo "Done! Use  K3B  or type in console :  "
echo "growisofs -dvd-compat -speed=8 -Z $dvd=$disktitle.iso "
echo "to burn the -$disktitle.iso- file created in the work folder." 
echo "==============================================================================="
     
exit

Last edited by Steel_J; 03-04-2005 at 10:48 AM.
 
Old 03-04-2005, 11:49 AM   #110
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
In the beginning, i get this:

****
libdvdcss is not detected, you need it to complete the process.
*****

However, it continues on anyways and almost finishes the process. In other words, i am left with a dvd_dvd folder and final.mpg. No iso or anything. Its giving this at the end:

=========================================
Authoring and generating a DVD structure
=========================================
DVDAuthor::dvdauthor, version 0.6.10.
Build options: gnugetopt magick iconv freetype fribidi
Send bugs to <dvdauthor-users@lists.sourceforge.net>

INFO: dvdauthor creating VTS
STAT: Picking VTS 01

STAT: Processing final.mpg...
STAT: VOBU 7280 at 1768MB, 1 PGCS
INFO: Video pts = 0.176 .. 3628.501
STAT: VOBU 7290 at 1771MB, 1 PGCS
INFO: Generating VTS with the following video attributes:
INFO: MPEG version: mpeg2
INFO: TV standard: ntsc
INFO: Aspect ratio: 4:3
INFO: Resolution: 720x480

STAT: fixed 7290 VOBUS
DVDAuthor::dvdauthor, version 0.6.10.
Build options: gnugetopt magick iconv freetype fribidi
Send bugs to <dvdauthor-users@lists.sourceforge.net>

INFO: dvdauthor creating table of contents
INFO: Scanning dv_dvd/VIDEO_TS/VTS_01_0.IFO
INFO: ISO-8859-1 character encoding detected by locale settings.
Assuming ISO-8859-1 encoded filenames on source filesystem,
use -input-charset to override.
mkisofs: No such file or directory. Invalid node - .iso

===============================================================================
Done! Use K3B or type in console :
growisofs -dvd-compat -speed=8 -Z /dev/hdc=.iso
to burn the -.iso- file created in the work folder.



I do have mkisofs installed in /usr/bin.
 
Old 03-04-2005, 12:07 PM   #111
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Alright, collaboration!

Steel_J - you can just remove that "audioa" line from the script. It doesn't do anything, and the value isn't used; the while-loop right after that calculates the sizes. Also, thanks for correcting the AID example; I didn't know for sure what AID numbers were common (since my DVD drive is still on the fritz and I can't test it).

We do need to find a better solution to that libdvdcss problem. It's cropped up a few times, and I've even had tovid users emailing saying that it's not detected for them, even when it's installed.

sk545 - not sure why the iso wouldn't be getting created... maybe Steel_J can help you there.
 
Old 03-04-2005, 12:25 PM   #112
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
Got your point re-reading the code. Removed the offending unused "audioa" line hahaha! Extra computations for nothing.

Now as for de libdvdcss problem you may have noticed that my dependency check for it is different from all others in the script. I wrote it so it would look for it but keep going anyway if it did not. The reason for that is the afformentionned bug.

It seems libdvdcss.so.2 is not found consistently for all distros and setups. I knew sk545 had it installed even if the script would'nt detect it so thats why I set it up this way until I got around to fix it, so he coul keep on using it and all other users with that problem.

So if users get the error messages but the scripts gets the job done in the end they should just ignore the libdvdcss error message for now.
 
Old 03-04-2005, 12:33 PM   #113
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
To sk545:

I need to know a few thing to help you.

1) Does your final.mpg play fine and is it 4.3 gigabytes in size?

2) What is the content of the VIDEO_TS folder in dv_dvd.

3) Could you send me the whole output from the script after running it again? Just copy and paste in you post.


I don't doubt that you do have mkisofs installed because the script would have exited otherwise if he could'nt find it.

It looks to me like a variable called : disktitle is not being used or created properly.

I will need a entire console output from you to see what happened.
 
Old 03-04-2005, 12:52 PM   #114
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
WapCaplet

Something is wrong. the outputed files, mpg and iso are the wrong size.

They are 4.7 gigs intead of the required 4.3 gigs.

that means the formula calculation is doing something wrong. I'm going to go run a few errands and comeback to look into this.

I pretty sure the AUDIO_SIZE is not taken into account somehow when calculating requantization values.

Last edited by Steel_J; 03-04-2005 at 12:54 PM.
 
Old 03-04-2005, 03:05 PM   #115
sk545
Member
 
Registered: Aug 2002
Posts: 312

Rep: Reputation: 30
Quote:
1) Does your final.mpg play fine and is it 4.3 gigabytes in size?
It plays fine till the end, but its only 1.9GB in size.


Quote:
2) What is the content of the VIDEO_TS folder in dv_dvd.
$ ls
VIDEO_TS.BUP VTS_01_0.BUP VTS_01_1.VOB
VIDEO_TS.IFO VTS_01_0.IFO VTS_01_2.VOB

Quote:
3) Could you send me the whole output from the script after running it again? Just copy and paste in you post.
/tmp$ ./dvrequant.sh

====================
* DVRequant v0.186a *
====================
Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd

growisofs or K3B are optional but recommended


***************************************************************
libdvdcss is not detected, you need it to complete the process.
***************************************************************

********************************************************************************
The script will keep going but may exit with errors when trying to read the DVD.
********************************************************************************

===============================
Reading from the config file...
===============================

A work folder will now be created with the name of the DVD movie
in /tmp. If you would like to use a different work folder, edit
/home/me/.dvrequant_config and change the LOC line.

libdvdread: Using libdvdcss version 1.2.8 for DVD access
mkdir: cannot create directory `/tmp/': File exists
libdvdread: Using libdvdcss version 1.2.8 for DVD access
libdvdread: Using libdvdcss version 1.2.8 for DVD access

***** The longest title is -18- and is -01:00:24 - long.*****

(Hint: If you don't want to be prompted for anything,
run this script with the -nohands option.)
If this is the video track you want, you can continue
automatically. If not, you can choose a different track
to rip. Use this track? (y or n) (default is -y-)>

Moving on to picking an audio track


=============================================
These are all the audio tracks for this title
=============================================

'-nojoystick' '-nortc' '-nolirc' '-dvd-device' '/dev/dvd' 'dvd://18' '-vo' 'null' '-ao' 'null' '-frames' '0' '-v'
libdvdread: Using libdvdcss version 1.2.8 for DVD access

libdvdread: Attempting to retrieve all CSS keys
libdvdread: This can take a _long_ time, please be patient

libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x0000016b
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_01_1.VOB at 0x0000503e
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_02_1.VOB at 0x000051cb
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_03_1.VOB at 0x000e772d
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_04_1.VOB at 0x001c0eed
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_05_1.VOB at 0x002a4421
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_06_1.VOB at 0x0038ccac
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_07_1.VOB at 0x003a5d0c
libdvdread: Elapsed time 0
libdvdread: Found 7 VTS's
libdvdread: Elapsed time 0
[open] audio stream: 0 audio format: ac3 (stereo) language: en aid: 128
Using 3DNowEx optimized IMDCT transform
Using MMX optimized resampler

Enter the audio ID (AID) codes of the tracks you wish to rip, separated by spaces (e.g. 128 129 etc...) >128

=================================================
The DVD will now be ripped, it may take some time
=================================================

===============================
Now ripping the audio stream(s)
===============================

MPlayer 1.0pre6-3.3.5 (C) 2000-2004 MPlayer Team
CPU: Advanced Micro Devices Athlon Thunderbird (Family: 6, Stepping: 2)
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 0 SSE2: 0
Compiled for Debian.


73 audio & 180 video codecs
Playing dvd://18.
libdvdread: Using libdvdcss version 1.2.8 for DVD access
Reading disc structure, please wait...
There are 23 titles on this DVD.
There are 37 chapters in this DVD title.
There are 1 angles in this DVD title.

libdvdread: Attempting to retrieve all CSS keys
libdvdread: This can take a _long_ time, please be patient

libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x0000016b
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_01_1.VOB at 0x0000503e
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_02_1.VOB at 0x000051cb
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_03_1.VOB at 0x000e772d
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_04_1.VOB at 0x001c0eed
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_05_1.VOB at 0x002a4421
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_06_1.VOB at 0x0038ccac
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_07_1.VOB at 0x003a5d0c
libdvdread: Elapsed time 0
libdvdread: Found 7 VTS's
libdvdread: Elapsed time 0
DVD successfully opened.
MPEG-PS file format detected.
Core dumped

Exiting... (End of file)

============================
Now ripping the video stream
============================

MPlayer 1.0pre6-3.3.5 (C) 2000-2004 MPlayer Team
CPU: Advanced Micro Devices Athlon Thunderbird (Family: 6, Stepping: 2)
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 0 SSE2: 0
Compiled for Debian.


73 audio & 180 video codecs
Playing dvd://18.
libdvdread: Using libdvdcss version 1.2.8 for DVD access
Reading disc structure, please wait...
There are 23 titles on this DVD.
There are 37 chapters in this DVD title.
There are 1 angles in this DVD title.

libdvdread: Attempting to retrieve all CSS keys
libdvdread: This can take a _long_ time, please be patient

libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x0000016b
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_01_1.VOB at 0x0000503e
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_02_1.VOB at 0x000051cb
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_03_1.VOB at 0x000e772d
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_04_1.VOB at 0x001c0eed
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_05_1.VOB at 0x002a4421
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_06_1.VOB at 0x0038ccac
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_07_1.VOB at 0x003a5d0c
libdvdread: Elapsed time 0
libdvdread: Found 7 VTS's
libdvdread: Elapsed time 0
DVD successfully opened.
Cache fill: 5.47% (57344 bytes) MPEG-PS file format detected.
Core dumped

Exiting... (End of file)

==================================
Calculating best requant factor...
==================================
===========================================
The closer to 1.00 the factor is the better
===========================================


======================================
Requant factor for this movie is: .39
======================================

=========================================
No requantization necessary. Skipping
=========================================

======================================
Multiplexing audio and video stream(s)
======================================

INFO: [mplex] mplex version 1.6.2 (2.2.3 $Date: 2004/01/13 20:45:26 $)
INFO: [mplex] File shrinked.m2v looks like an MPEG Video stream.
INFO: [mplex] File lang0.ac3 looks like an AC3 Audio stream.
INFO: [mplex] Video stream 0: profile 8 selected - ignoring non-standard options!
INFO: [mplex] Found 1 audio streams and 1 video streams
INFO: [mplex] Selecting dvdauthor DVD output profile
INFO: [mplex] Multiplexing video program stream!
INFO: [mplex] Scanning for header info: Video stream e0 (shrinked.m2v)
INFO: [mplex] VIDEO STREAM: e0
INFO: [mplex] Frame width : 720
INFO: [mplex] Frame height : 480
INFO: [mplex] Aspect ratio : 4:3 display
INFO: [mplex] Picture rate : 29.970 frames/sec
INFO: [mplex] Bit rate : 7500000 bits/sec
INFO: [mplex] Vbv buffer size : 229376 bytes
INFO: [mplex] CSPF : 0
INFO: [mplex] Scanning for header info: AC3 Audio stream 00 (lang0.ac3)
INFO: [mplex] AC3 frame size = 768

INFO: [mplex] AC3 AUDIO STREAM:
INFO: [mplex] Bit rate : 24576 bytes/sec (192 kbit/sec)
INFO: [mplex] Frequency : 48000 Hz
INFO: [mplex] SYSTEMS/PROGRAM stream:
INFO: [mplex] rough-guess multiplexed stream data rate : 7855600
INFO: [mplex] target data-rate specified : 10080000
INFO: [mplex] Setting specified specified data rate: 10080000
INFO: [mplex] Run-in Sectors = 89 Video delay = 13019 Audio delay = 16022
INFO: [mplex] New sequence commences...
INFO: [mplex] Video e0: buf= 237568 frame=000000 sector=00000000
INFO: [mplex] Audio bd: buf= 16384 frame=000000 sector=00000000
INFO: [mplex] Scanned to end AU 108740
++ WARN: [mplex] No seq. header starting new sequence after seq. end!
INFO: [mplex] STREAM e0 completed @ frame 108740.
INFO: [mplex] STREAM bd completed @ frame 113385.
INFO: [mplex] Multiplex completion at SCR=326507373.
INFO: [mplex] Video e0: buf= 91984 frame=108740 sector=00899569
INFO: [mplex] Audio bd: buf= 1024 frame=113385 sector=00043195
INFO: [mplex] VIDEO_STATISTICS: e0
INFO: [mplex] Video Stream length: 1814143797 bytes
INFO: [mplex] Sequence headers: 7306
INFO: [mplex] Sequence ends : 1
INFO: [mplex] No. Pictures : 108740
INFO: [mplex] No. Groups : 7306
INFO: [mplex] No. I Frames : 7307 avg. size 60871 bytes
INFO: [mplex] No. P Frames : 36252 avg. size 28356 bytes
INFO: [mplex] No. B Frames : 65182 avg. size 5237 bytes
INFO: [mplex] Average bit-rate : 3999600 bits/sec
INFO: [mplex] Peak bit-rate : 11065200 bits/sec
INFO: [mplex] BUFFERING min 15 Buf max 153736
INFO: [mplex] AUDIO_STATISTICS: bd
INFO: [mplex] Audio stream length 87080448 bytes.
INFO: [mplex] Frames : 2391540499
INFO: [mplex] BUFFERING min 67 Buf max 7939
INFO: [mplex] MUX STATUS: no under-runs detected.

=========================================
Authoring and generating a DVD structure
=========================================
DVDAuthor::dvdauthor, version 0.6.10.
Build options: gnugetopt magick iconv freetype fribidi
Send bugs to <dvdauthor-users@lists.sourceforge.net>

INFO: dvdauthor creating VTS
STAT: Picking VTS 01

STAT: Processing final.mpg...
STAT: VOBU 7280 at 1852MB, 1 PGCS
INFO: Video pts = 0.178 .. 3628.502
INFO: Audio[0] pts = 0.178 .. 3628.530
STAT: VOBU 7290 at 1855MB, 1 PGCS
INFO: Generating VTS with the following video attributes:
INFO: MPEG version: mpeg2
INFO: TV standard: ntsc
INFO: Aspect ratio: 4:3
INFO: Resolution: 720x480
INFO: Audio ch 0 format: ac3/2ch, 48khz drc

STAT: fixed 7290 VOBUS
DVDAuthor::dvdauthor, version 0.6.10.
Build options: gnugetopt magick iconv freetype fribidi
Send bugs to <dvdauthor-users@lists.sourceforge.net>

INFO: dvdauthor creating table of contents
INFO: Scanning dv_dvd/VIDEO_TS/VTS_01_0.IFO
INFO: ISO-8859-1 character encoding detected by locale settings.
Assuming ISO-8859-1 encoded filenames on source filesystem,
use -input-charset to override.
mkisofs: No such file or directory. Invalid node - .iso

===============================================================================
Done! Use K3B or type in console :
growisofs -dvd-compat -speed=8 -Z /dev/hdc=.iso
to burn the -.iso- file created in the work folder.
 
Old 03-04-2005, 05:58 PM   #116
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
Quote:
Originally posted by sk545
Wow, you guys have to try out the KDE DVD Authoring Wizard, its very nicely done. [/B]
Those are cool! Kommander looks like it gives a very nice, step-by-step kind of interface. (Looks like it doesn't convert arbitrary videos to DVD format, though, so tovid is one step ahead of it there )

It would definitely be good to include that sort of interface in tovid someday (a "wizard"-style approach, that takes the user through each step). It already kind of uses a wizard approach, but with many more things to do in each step. I like the idea of keeping it very simple: "Pick some videos to play", "Choose a menu font", etc. I'll try to include something like this down the road.

I think for now, the dvrequant interface for tovid will be sort of like a graphical configuration file, with the same options to select as the script provides (DVD device, working directory, tracks to rip, etc.) I've already started working on the GUI frontend for it, but it won't appear until a later release (not 0.18).

I've also made a "Mini editor" for inclusion in tovid. It can create, open, edit, and save short text files. It's sort of like a Windows Notepad built into tovid. I figure there will occasionally be a need to edit small config files or whatnot; for instance, maybe an option to edit the dvdauthor/vcdxbuild XML file prior to authoring, or edit the dvrequant config file. It's finished and working, so it could be included at any time.
 
Old 03-04-2005, 07:43 PM   #117
wapcaplet
LQ Guru
 
Registered: Feb 2003
Location: Colorado Springs, CO
Distribution: Gentoo
Posts: 2,018

Rep: Reputation: 48
My DVD drive seems to be working now, so I've been working on the script. I've done a lot of cleanup; variable names changed to all-caps and renamed to make their purpose clearer, a lot of 'cut' commands altered to use fields of text, rather than literal text locations (slightly more robust, but still not perfect). I added several more checks for libdvdcss.so.2, so hopefully it will be found if it's there. We could also do a "find / -name libdvdcss.so.2" but that would take forever, and isn't very reliable (since it'll find it, even if it's not usable).

I haven't tested it very much yet, so let me know if you guys find any problems.

Code:
#! /bin/bash

# DVrequant script   

# Will rip a DVD-9 disc with the  title and audio of your
# choice and requantize it to fit on a DVD-R 4.7
# Steel_J  2005-03-04

# Additional code for chaptering and error checking from Eric Pierce (WapCaplet) 2005-03-04
# Set to read from config file and work hands free by Daniel Patterson (KillFire) 2005-02-24
# Without these guys this script would'nt have been the same.

# This software is licensed under GPL.

# Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd / K3B

#===========================================================================

# DEFAULTS AND FUNCTION DEFINITIONS
# Configuration file
CONFIG_FILE=~/.dvrequant_config
# Hands-free operation? (empty == no)
NOHANDS=""
# Have libdvdcss? (assume no until it's found)
HAVE_CSS=""
# Name for video output and shrunk files
VIDEO_OUTPUT="video_out.m2v"
VIDEO_SHRUNK="video_shrunk.m2v"

# Take an integer number of seconds and format it as hours:minutes:seconds
# Echoes result to stdout, so in order to use the output as a "return value",
# call the function like this:
#   RETURN_VALUE=$( format_time $NUM_SECONDS )
format_time ()
{
  let "HMS_HOURS=$1 / 3600"
  let "HMS_MINS=( $1 % 3600 ) / 60"
  let "HMS_SECS=$1 % 3600 % 60"

  [[ $HMS_HOURS -lt 10 ]] && HMS_HOURS="0${HMS_HOURS}"
  [[ $HMS_MINS -lt 10 ]] && HMS_MINS="0${HMS_MINS}"
  [[ $HMS_SECS -lt 10 ]] && HMS_SECS="0${HMS_SECS}"

  echo "${HMS_HOURS}:${HMS_MINS}:${HMS_SECS}"
}

# Take a string containing a time (like "02:15:25.3") and
# format it as an integer number of seconds. Fractional seconds
# are truncated. Result is echoed to stdout, so to use the output
# as a "return value", call the function like this:
#   RETURN_VALUE=$( unformat_time $TIME_STRING )
unformat_time ()
{
  HMS_HOURS=$( echo $1 | sed -r -e 's/0?([0-9]+):0?([0-9]+):0?([0-9]+)(\.[0-9])?/\1/' )
  HMS_MINS=$( echo $1 | sed -r -e 's/0?([0-9]+):0?([0-9]+):0?([0-9]+)(\.[0-9])?/\2/' )
  HMS_SECS=$( echo $1 | sed -r -e 's/0?([0-9]+):0?([0-9]+):0?([0-9]+)(\.[0-9])?/\3/' )
  let "TOT_SECONDS=$HMS_HOURS * 3600 + $HMS_MINS * 60 + $HMS_SECS"
  echo $TOT_SECONDS
}

# Retrieve the chapter breaks from the specified track on the DVD.
# Echoes a string to stdout with a list of chapter-start times
# (i.e., "0, 1:53, 15:26, 1:23:15" etc.)
# To use output as a "return value", call the function like this:
#   CHAPTER_START_TIMES=$( get_chapters $TITLE )
get_chapters ()
{
  CH_LIST=$( lsdvd -c -t $1 2>&1 | grep "Chapter:" | \
      sed -r -e 's/^.* Length: ([^,]+).*$/\1/' )
  
  # Assemble the list
  echo -n "0"
  TOTAL_SECS=0
  for CUR_CHAP in $CH_LIST; do
    CUR_SECS=$( unformat_time $CUR_CHAP )
    # Don't insert markers for 0-second chapters
    if [[ $CUR_SECS -gt 0 ]]; then
      let "TOTAL_SECS=$TOTAL_SECS + $CUR_SECS"
      CUR_TIME=$( format_time $TOTAL_SECS )
      echo -n ",$CUR_TIME"
    fi
  done
}

# Presentation

clear
version=0.186a

echo -e "===================="
echo -e "* DVRequant v${version} *"
echo -e "===================="

echo "Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs)  / lsdvd "
echo " "
echo "growisofs or K3B are optional but recommended"
echo " "

#============================================================================
# checking for needed software

if [[ -z $( type -p mplayer ) ]]; then
  echo " "
  echo "mplayer is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if [[ -z $( type -p transcode ) ]]; then
  echo " " 
  echo "transcode is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if [[ -z $( type -p mpeg2enc ) ]]; then
  echo " "
  echo "mjpegtools is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if [[ -z $( type -p dvdauthor ) ]]; then
  echo " "
  echo "dvdauthor is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if [[ -z $( type -p mkisofs ) ]]; then
  echo " "
  echo "cdrecord (mkisofs) is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

if [[ -z $( type -p lsdvd ) ]]; then
  echo " "
  echo "lsdvd is not detected";
  echo "you need it installed. Exiting...";
  echo " "
  false; exit;
fi

# Try to find libdvdcss.so.2, looking first in the most obvious places
if [[ $( type -p /usr/lib/libdvdcss.so.2 ) ]]; then HAVE_CSS="y"
elif [[ $( type -p /usr/local/lib/libdvdcss.so.2 ) ]]; then HAVE_CSS="y"
elif [[ $( slocate libdvdcss.so.2 | head -n 1 ) ]]; then HAVE_CSS="y"
fi

if [[ -z $HAVE_CSS ]]; then
  echo " "
  echo "*************************************************************** "
  echo "libdvdcss is not detected, you need it to complete the process.";
  echo "*************************************************************** "
  echo " "
  echo "******************************************************************************** "
  echo "The script will keep going but may exit with errors when trying to read the DVD. "
  echo "******************************************************************************** "
  echo " "
fi

#==========================================================================
# Read command-line arguments
while [[ ${1:0:1} == "-" ]]; do
  if [[ $1 == "-nohands" ]]; then NOHANDS="y"
  # More arguments can go here someday
  fi
  # Get next argument
  shift
done

# Read config file

echo "==============================="
echo "Reading from the config file..."
echo "==============================="
echo " "

# If config file doesn't exist, create it
if [[ ! -e "$CONFIG_FILE" ]]; then
	echo "DVD_DEVICE /dev/dvd" > "$CONFIG_FILE"
  echo "WORKING_DIR /home/$USER" >> "$CONFIG_FILE"
fi

WORKING_DIR=$( eval "echo `cat "$CONFIG_FILE" | grep "^WORKING_DIR" | cut -d \" \" -f 2`" )

# If working directory doesn't exist, create it
if [[ ! -d "$WORKING_DIR" ]]; then
	mkdir "$WORKING_DIR"
fi

DVD_DEVICE=`cat $CONFIG_FILE | grep "^DVD_DEVICE" | cut -d " " -f 2`

#===========================================================================
# Create project folder and choose preferences

echo "A work folder will now be created with the name of the DVD movie"
echo "in $WORKING_DIR. If you would like to use a different work folder, edit"
echo "$CONFIG_FILE and change the WORKING_DIR line."
echo " "

DISK_TITLE=`lsdvd $DVD_DEVICE -q | grep Disc | cut -d " " -f 3`

# If a project directory doesn't exist, create it
if [[ ! -d $DISK_TITLE ]]; then
  mkdir "$WORKING_DIR/$DISK_TITLE"
else
  echo "Directory $WORKING_DIR/$DISK_TITLE already exists. Continuing."
fi

    
#==========================================================================
# video stream sub-section
# choose the longest title
      
TITLE_NUM=`lsdvd $DVD_DEVICE | grep Longest | cut -d " " -f 3` 
TITLE_LENGTH=`lsdvd $DVD_DEVICE -q -t $TITLE_NUM | grep Length: | cut -d " " -f 4`

echo " "
echo "***** The longest title is -$TITLE_NUM- and is -$TITLE_LENGTH- long.*****"
echo " "

# If doing hands-free operation, assume "y" and continue
if [[ $NOHANDS == "y" ]]; then
  DEFAULT_TITLE_OK="y"
  echo "Hands-free operation. This track will be used automatically."
# Otherwise, prompt for whether to continue
else
  echo "(Hint: If you don't want to be prompted for anything,"
  echo "run this script with the -nohands option.)"
  echo "If this is the video track you want, you can continue"
  echo "automatically. If not, you can choose a different track"
  echo "to rip. Use this track? (y or n) (default is -y-)>"
fi

read DEFAULT_TITLE_OK
 
# If the default title is not what user wanted, prompt for what title to rip
if [[ "$DEFAULT_TITLE_OK" == "n" || "$DEFAULT_TITLE_OK" == "N" ]]; then
	     
  # Ask the user which video title to rip from DVD
  echo " "
  echo "========================================== "
  echo "These are all the video titles on the disc"
  echo "========================================== "
  echo " "
    
  lsdvd  -v $DVD_DEVICE | more

  echo " "
  echo -n "What title do you want to rip? (ex. 1, 2 or 3) >"
       
  read -e TITLE_NUM
     
  echo " "
  echo "===================== "
  echo "You picked title >#" $TITLE_NUM
  echo "===================== "
  lsdvd -t $TITLE_NUM | more

# If it's what the user wanted, skip title selection
else
  echo " Moving on to picking an audio track "
  echo " "
fi    
      
# Construct the basic mplayer command to use
MPLAYER_CMD="mplayer -nojoystick -nolirc -dvd-device $DVD_DEVICE dvd://$TITLE_NUM"

#audio stream sub-section
 
echo " "
echo "============================================= "
echo "These are all the audio tracks for this title"
echo "============================================= "
echo " "

eval $( echo "$MPLAYER_CMD -vo null -ao null -frames 0 -v | grep aid" )

CHAPTER_START_TIMES=$( get_chapters $TITLE_NUM )

echo " "
echo -n "Enter the audio ID (AID) codes of the tracks you wish to rip, separated by spaces (e.g. 128 129 etc...) >"

read -a TRACK_AID

NUM_AUD_TRACKS=${#TRACK_AID[@]}
CUR_TRACK=0
while [[ "$CUR_TRACK" -lt "$NUM_AUD_TRACKS" ]]; do
  AUD_FILE[$CUR_TRACK]=$( echo "lang$CUR_TRACK.ac3" )
  (( CUR_TRACK++ ))
done


# Inform user of what's about to happen
echo " "
echo "================================================= "
echo "The DVD will now be ripped, it may take some time"
echo "================================================= "
echo " "

# Keep the user  informed on the progress
echo "=============================== "
echo "Now ripping the audio stream(s)"
echo "=============================== "
echo " "

# Rip each audio track
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
  eval $( echo "$MPLAYER_CMD -dumpaudio -aid ${TRACK_AID[ $CUR_TRACK ]} \
            -dumpfile \"$WORKING_DIR/$DISK_TITLE/${AUD_FILE[ $CUR_TRACK ]}\"" )
  (( CUR_TRACK++ ))
done

# Moving on to video...
echo " "
echo "============================ "
echo "Now ripping the video stream"
echo "============================ "
echo " "

# Rip the video track
eval $( echo "$MPLAYER_CMD -dumpvideo -dumpfile \"$WORKING_DIR/$DISK_TITLE/$VIDEO_OUTPUT\"" )

# If you are including more than one audio stream or a subtitle stream, those   
# filesizes must also be subtracted from the maximum dvd image size.
   
echo " "
echo "================================== "
echo "Calculating best requant factor..."
echo "================================== "
echo "==========================================="
echo "The closer to 1.00 the factor is the better"
echo "=========================================== "
echo " "
 
cd "$WORKING_DIR/$DISK_TITLE"
    
VIDEO_SIZE=`du -b $VIDEO_OUTPUT | cut -f 1`

# Add up audio sizes for all tracks
CUR_TRACK=0
AUDIO_SIZE=0
while [[ $CUR_TRACK -lt $NUM_AUDIO_TRACKS ]]; do
  AUDIO_SIZE=$(( $AUDIO_SIZE + `du -b ${AUD_FILE[ $CUR_TRACK ]} | cut -f 1` ))
  (( CUR_TRACK++ ))
done
                  
# Calculate requantization factor to use
SPACE_AVAILABLE=$(( 4700000000 - $AUDIO_SIZE ))
RATIO=$( echo "scale=2; $VIDEO_SIZE/$SPACE_AVAILABLE" | bc )
QUANT_FACTOR=$( echo "scale=2; $RATIO*1.05" | bc )
			 
echo " " 
echo "====================================== "
echo "Requant factor for this movie is: $QUANT_FACTOR"
echo "====================================== "
echo " "

#echo " "
#echo "====================================== "
#echo "You can eject the DVD now if you want."
#echo "====================================== "
#echo " "
  
#========================================================================    

# Requantize it, if necessary:

if [[ $( echo "$QUANT_FACTOR > 1.00" | bc ) == "1" ]]; then
  echo "========================================= "
  echo "Requantizing (shrinking) the video stream"
  echo "========================================= "
  tcrequant -d2 -i "$VIDEO_OUTPUT" -o "$VIDEO_SHRUNK" -f $QUANT_FACTOR
  # Don't need original video anymore
  rm "$VIDEO_OUTPUT"
else
  echo "========================================= "
	echo "No requantization necessary. Skipping"
  echo "========================================= "
  mv "$VIDEO_OUTPUT" "$VIDEO_SHRUNK"
fi

#========================================================================
     
# Remultiplex:

echo " "
echo "====================================== "
echo "Multiplexing audio and video stream(s)"
echo "====================================== "
echo " "
 
# Construct a multiplexing command, listing all the
# language tracks.
MPLEX_CMD="mplex -f 8 -o final.mpg $VIDEO_SHRUNK"
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
  MPLEX_CMD=$( echo " $MPLEX_CMD ${AUD_FILE[ $CUR_TRACK ]}" )
   (( CUR_TRACK++ ))
done

eval "$MPLEX_CMD"
				    
# Cleaning up
CUR_TRACK=0
while [[ $CUR_TRACK -lt $NUM_AUD_TRACKS ]]; do
  rm ${AUD_FILE[ $CUR_TRACK ]}
   (( CUR_TRACK++ ))
done
rm $VIDEO_SHRUNK    
   
#========================================================================     
# Re-author it
# This will create a folder named "dv_dvd" and generate inside it
# a dvd structure -- VIDEO_TS and AUDIO_TS

echo " "
echo "========================================= "
echo "Authoring and generating a DVD structure"
echo "========================================= "

# Populate filesystem
dvdauthor  -t  -o  dv_dvd  -c $CHAPTER_START_TIMES final.mpg
	   
# Create IFO files
dvdauthor -o dv_dvd -T 
		    
# Create DVD Video compliant ISO image
mkisofs -dvd-video -udf -V $DISK_TITLE -o $DISK_TITLE.iso "$WORKING_DIR/$DISK_TITLE"
	       
#========================================================================       
# End messages

echo " "
echo "==============================================================================="
echo "Done! Use  K3B  or type in console :  "
echo "growisofs -dvd-compat -speed=8 -Z $DVD_DEVICE=$DISK_TITLE.iso "
echo "to burn the -$DISK_TITLE.iso- file created in the work folder." 
echo "==============================================================================="
     
exit
 
Old 03-04-2005, 08:10 PM   #118
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
I will test it as soon as I find a fix for the wrong size output files. (As described in my above post.)

I am trying to play around with the syntax from your modified formula. You renamed the variables and introduced new ones so I have to re-familiarized my brain with them and also figure out were this new calculation bug comes from.

Output of final.mpg, dv_dvd and the iso file must be of 4.3 gigs. Not 4.7 as it is now.

So to get back to normal I will have to do a lot of trial and error runs. Be patient.

I am also working on a simple installer to install dvrequant with the proper permissions to the /usr/bin directory and also install the config file. This will be all zipped up as a standalone version for people who want dvrequant only.
 
Old 03-04-2005, 08:17 PM   #119
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
To SK545

My friend, since you were my main goto beta tester guy, and sill are I would like to have your real name because I am modifying
the comments caption of the script to include everybody who made a large contribution.

So far it looks like this:

Quote:
# DVrequant script

# Will rip a DVD-9 disc with the title and audio of your
# choice and requantize it to fit on a DVD-R 4.7
# Jean-François Ouellette (Steel_J) 2005-03-04

# Additional effiency, formatting and general function code from Eric Pierce (WapCaplet) 2005-03-04
# Set to read from config file and work hands free by Daniel Patterson (KillFire) 2005-02-24
# Special thanks to SK545 (real name here) for is beta testing efforts and precious feedback 2005-03-04
# Without these guys this script would'nt have been what it is today.

# This software is licensed under the GNU General Public License
# For the full text of the GNU GPL, see:
#
# http://www.gnu.org/copyleft/gpl.html
#
# No guarantees of any kind are associated with use of this software.

# Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd / K3B

You can send this info to me at : steel_j1971@yahoo.ca

It's not much but it's important to do it I think.
 
Old 03-04-2005, 09:05 PM   #120
Steel_J
Member
 
Registered: Oct 2004
Location: Montreal, Canada
Distribution: Kubuntu 10.04, Mint 8 and Puppy 4.3.1
Posts: 355
Blog Entries: 1

Original Poster
Rep: Reputation: 31
Tested the new code.

Got an error right away. It cannot create the work folder:

Figured out you have to modify the dvrequant_config files before use.

Here is the new dvrequant_config file code :

Code:
# Config file for DVRequant
# Daniel Patterson 2-24-05
# its very simple. Comments dont exist, they are here
# by convention. It searches for the all capital 
# key words, and uses the rest of the line as the value.

# dvd device
DVD_DEVICE /dev/dvd

# location for storage
WORKING_DIR /home/$USER

Last edited by Steel_J; 03-04-2005 at 09:15 PM.
 
  


Reply

Tags
k9copy


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] DVD9 to DVD5 guide Steel_J Linux - Software 62 05-08-2011 11:27 AM
problem at step 5 in "DVD9 to DVD5 guide" Vindane Linux - Software 5 04-24-2005 02:25 PM
DVD backup DVD9 to DVD5 ksgill Linux - Newbie 7 03-05-2005 04:08 PM
DVD9 to DVD5 Klas Linux - Software 2 12-15-2004 01:45 AM
DVD9 to DVD5 Avo Linux - Software 3 10-20-2004 05:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General > LinuxAnswers Discussion

All times are GMT -5. The time now is 09:41 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration