Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Multimedia
  • Search

dvd9 to dvd5...enjoy!

Help with creation, editing, or playback of sounds, images, or video. Amarok, audacious, mplayer, grip, cdparanoia and anything else that makes a sound or plays a video.
Post Reply
Advanced search
40 posts
  • 1
  • 2
  • Next
Author
Message
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

dvd9 to dvd5...enjoy!

  • Quote

Post by max-232 » Sat Feb 24, 2007 12:37 pm

backDvd has now a place in which it will be updated! for the latest version, please go here:
http://www.cli-apps.org/content/show.ph ... tent=69322

PLEASE NOTE A NEW VERSION SOME REPLIES BELOW!!!

Hello people,

after a lot of work, I would like to share with you my work.
this is a vamps based bash script to backup dvd9 to dvd5.
I know that there are a lot of solutions...but if you still seeking for, I purpose you the mine one.

features: angle-managing, vamps for better backups, works with >2.6.19 kernels, audio and subtitles managing, and many others....

the story of this script is there http://forums.gentoo.org/viewtopic-t-457186.html

...enjoy!

Code: Select all

#!/bin/bash
#
# to use backDvd you need: libdvdread vamps lsdvd dvdauthor
# optional: mplayer cdrtools
#
# All is born here http://forums.gentoo.org/viewtopic-t-457186.html
# Thanks a lot to ~L~ and his halkase script. I copy the structure of backDvd from halkase.


# let's start!
clear
echo " "
echo "########################################################################"
echo "#                                                                      #"
echo "#                        This is backDvd 1.1 rc8                       #"
echo "#                                                                      #"
echo "#      A script for backing up DVD9 main title to DVD5 - by yknuk      #"
echo "#                                                                      #"
echo "#         This software is distributed under the GNU GPL terms.        #"
echo "#                                                                      #"
echo "#                 Use this software at your own risk!                  #"
echo "#             backDvd comes with absolutely NO WARRANTY!               #"
echo "#               Don't blame me if your PC get crashed!                 #"
echo "########################################################################"
echo " "
echo " "
echo "* Welcome to backDvd! Press Enter key to start! (CTRL+C to exit)"
read junk


# check programs...
        # checking for vamps...
        if [ ! -f "/usr/bin/vamps" ]
        then
        echo "* !!! You don't have vamps-0.99.2 installed... please provide!"
        exit
        fi


        # checking for play_cell...
        if [ ! -f "/usr/bin/play_cell" ]
        then
        echo "* !!! You don't have play_cell (vamps-0.99.2) installed... please provide!"
        exit
        fi


        # checking for libdvdread...
        if [ ! -f "/usr/lib/libdvdread.so" ]
        then
        echo "* !!! You don't have libdvdread installed... please provide!"
        exit
        fi


        # checking for ifo_dump_dvdread...
        if [ ! -f "/usr/bin/ifo_dump_dvdread" ]
        then
        echo "* !!! You don't have ifo_dump_dvdread (at least libdvdread-0.9.6) installed... please provide!"
        exit
        fi


        # checking for mplayer...
        if [ ! -f "/usr/bin/mplayer" ]
        then
		clear
		echo "#   backDvd   #"
		echo " "
		echo "* !!! You don't have mplayer installed!"
		echo "* !!! If you continue you'll not able to see the preview!"
		echo -n "* !!! Do you want to continue? (yes/no)"
		 read -e prev
		if [ "$prev" = "yes" ]
		then
		  preview="no"
		else
		exit
		fi
	else
	preview="yes"
	fi


        # checking for lsdvd...
        if [ ! -f "/usr/bin/lsdvd" ]
        then
        echo "* !!! You don't have lsdvd installed... please provide!"
        exit
        fi


        # checking for dvdauthor...
        if [ ! -f "/usr/bin/dvdauthor" ]
        then
        echo "* !!! You don't have dvdauthor installed... please provide!"
        exit
        fi


        # checking for cdrtools (mkisofs)...
        if [ ! -f "/usr/bin/mkisofs" ]
        then
		clear
		echo "#   backDvd   #"
		echo " "
		echo "* !!! You don't have cdrtools installed!"
		echo "* !!! If you continue you'll not able to create the iso file and/or burn the dvd!"
		echo -n "* !!! Do you want to continue? (yes/no)"
		 read -e isofs
		if [ "$isofs" = "yes" ]
		then
		  createiso="no"
		else
		exit
		fi
	else
	createiso="yes"
	fi


# change that for meet your defaults...
home=~
#home="/home/backup"
defaultworkingdir="$home/film-dvd"
defaultdvd="/dev/dvd"


        # go to the working directory...
	clear
	echo "#   backDvd   #"
	echo " "
        echo -n "* What is your working directory? (default $defaultworkingdir) : "
         read -e working
        if [ -z "$working" ]
        then
          working="$defaultworkingdir"
        fi


        # check the default working dir...
        if [ ! -d "$working" ]
	then
	echo " "
        echo "* Creating directory $working"
        mkdir $working 
        fi


        # enter working dir...
	cd $working
	if [ -d backDvd ]
	then
	echo " "
	echo "* Cleaning backDvd dir..."
	rm -rf backDvd
	fi
	mkdir backDvd
        cd backDvd


# where to read...
clear
echo "#   backDvd   #"
echo " "
echo -n "* Where is your dvd device? (default $defaultdvd ): "
 read -e device
if [ -z "$device" ]
then
  device="$defaultdvd"
fi
echo " "


# grab dvd name...
defaultname=$( lsdvd | head -n 1 | tail -n 1 | awk -F' ' '{ print $3 }' )


# title name...
clear
echo "#   backDvd   #"
echo " "
echo -n "* What shall we call it? (default $defaultname): "
 read -e dvdname
if [ -z "$dvdname" ]
then
  dvdname="$defaultname"
fi
	if [ -d $working/$dvdname ]
	then
	echo " "
	echo "* A folder with the name \"$defaultname\" already exist!"
	echo " "
	echo -n "* I must DELETE it!!! Continue (yes/no)? (default no): "
	 read -e delete
		if [ "$delete" = "yes" ]
		then
		rm -rf $working/$dvdname
		echo "* Folder Deleted. continuing..."
		else
		exit
		fi
	fi
echo " "
mkdir $working/$dvdname


# what's in the dvd...
mai1=$( lsdvd | grep "Longest track:" | awk -F' ' '{ print $3 }' )
mai=$mai1
clear
echo "#   backDvd   #"
echo " "
echo "* These are the longest title/s on the dvd:"
echo " "
list=$( lsdvd | grep -v "Length: 00" | grep -v Disc | grep -v Longest | grep " " )
echo "$list"
echo " "


# which title to backup...
echo -n "* Which one do you want to backup? (default $mai) "
read -e main
if [ -z "$main" ]
then
  main="$mai"
fi


# and then audio...
clear
echo "#   backDvd   #"
echo " "
echo "* These are the audio track for the titles $main: "
echo " "
lsdvd -t $main -a | grep Audio: | awk -F' ' '{ print $2,$5,$6,$5,$13,$14,$5,$8 }' | perl -pi -e 's/,$//g' | perl -pi -e 's/,//g'
echo " "
echo -n "* How many audio tracks do you want to backup? ( default 1 ) "
read -e numaud
if [ -z "$numaud" ]
then
numaud=1
fi
numaudplus=$[ 1 + $numaud ]
counter=1
while [  $counter -lt $numaudplus ]; do
echo -n "* Which language do you want to be the number $counter of $numaud? ( example: 1 ) "
read -e aidz
if [ -z "$aidz" ]
then
echo " "
echo "* You have to select the language, not just press enter! exiting..."
exit
fi
language=$( lsdvd -t $main -a | grep "Audio: $aidz" |  awk -F' ' '{ print $4 }' )
if [ "$counter" = "1" ]
then
audpostorder="$counter"
aidcount="$aidz"
langs="$language"
else
audpostorder="$audpostorder,$counter"
aidcount="$aidcount,$aidz"
langs="$langs $language"
fi
counter=$( echo "scale=2; $counter + 1 " | bc )
done


# and the subtitles...
clear
echo "#   backDvd   #"
echo " "
echo -n "* Do you want to add subtitle tracks on your backup (yes/no)? (default no) "
read -e suba
if [ -z "$suba" ]
then
suba="no"
fi
if [ "$suba" = "yes" ]
then
echo " "
echo "* These are the avilable subtitles for the title $main:"
echo " "
lsdvd -t $main -s | grep Subtitle: | awk -F' ' '{ print $2,$5,$6 }' | perl -pi -e 's/,$//' | perl -pi -e 's/,//'
echo " "
echo -n "* How many subtitles do you want to backup? ( default 1 ) "
read -e numsub
if [ -z "$numsub" ]
then
numsub=1
fi
numsubplus=$[ 1 + $numsub ]
counter=1
while [  $counter -lt $numsubplus ]; do
echo -n "* Which subtitle do you want to be the number $counter of $numsub? ( example: 01 ) "
read -e nub
if [ -z "$nub" ]
then
echo " "
echo "* You have to select the subtitle, not just press enter! exiting..."
exit
fi
nubz=$( lsdvd -t $main -s | grep "Subtitle: $nub" | awk -F' ' '{ print $4 }' )
if [ "$counter" = "1" ]
then
subpost="$counter"
sidcount="$nub"
sub="$nubz"
else
subpost="$subpost,$counter"
sidcount="$sidcount,$nub"
sub="$sub $nubz"
fi
counter=$( echo "scale=2; $counter + 1 " | bc )
done
echo " "
fi


# angles...
ang=$( lsdvd -t $main -n 2>/dev/null | grep "Angles: " | awk -F' ' '{ print $4 }' )
if [ "$ang" = "1" ]
then
target=$ang
else
chang=yes
clear
echo "#   backDvd   #"
echo " "
echo "* There are $ang angles for this title."
echo " "
echo -n "* Wich one do you want to keep? ( default: 1 ) "
read -e target
if [ -z "$target" ]
then
target=1
fi
fi


# generate cell list...
echo " "
echo "* Retrieving cell list from DVD..."
cells=$( lsdvd -t $main -d | grep Cell: | awk -F' ' '{ print $2 }' | perl -pi -e 's/\n//' | perl -pi -e 's/,/ /g' )
ma=$( echo "$main" | bc )
pgc=$( title_info $defaultdvd | grep -A 1 "Title $ma:" | grep TTN | awk -F' ' '{ print $5}' | perl -pi -e 's/]$//' )
vts=$( title_info $defaultdvd | grep -A 1 "Title $ma:" | grep VTS | awk -F' ' '{ print $3}' )


# regenerate $cells angle-compliant, if needed...
if [ "$ang" -gt "1" ]
then
dangl=$( ifo_dump_dvdread $defaultdvd $vts | grep "block angle" | grep "first" | awk -F' ' '{ print $2 }' )
if [ "$target" -ne "1" ]
then
count1=1
count2=1
while [ "$count1" -le "$ang" ]; do
	if [ "$count1" -ne "$target" ]
	then
		if [ "$count2" -eq "1" ]
		then
		dellist=$( echo "$dangl" )
		count2=$( echo "scale=2; $count2 + 1 " | bc )
		else
		dellist=$( echo "$dellist" $'\n' "$dangl" )
		fi
	dangl=$( echo "$dangl" | awk -F' ' '{ print $1"+1" }' | bc )
	fi
count1=$( echo "scale=2; $count1 + 1 " | bc )
done
else
count1=1
count2=1
while [ "$count1" -le "$ang" ]; do
	if [ "$count1" -ne "$target" ]
	then
		if [ "$count2" -eq "1" ]
		then
		dangl=$( echo "$dangl" | awk -F' ' '{ print $1"+1" }' | bc )
		dellist=$( echo "$dangl" )
		count2=$( echo "scale=2; $count2 + 1 " | bc )
		else
		dangl=$( echo "$dangl" | awk -F' ' '{ print $1"+1" }' | bc )
		dellist=$( echo "$dellist" $'\n' "$dangl" )
		fi
	fi
count1=$( echo "scale=2; $count1 + 1 " | bc )
done
fi
dellist=$( echo $dellist )
cells=$( echo $cells | perl -pi -e 's/\s+/\n/g' )
for x in $dellist
do
	if [ $x -lt 10 ]
	then 
	y="0$x"
	cells=$(echo "$cells" | grep -v "$y")
	else
	cells=$(echo "$cells" | grep -v "$x")
	fi
done
cells=$( echo $cells )
fi


# recap...
clear
echo "#   backDvd   #"
echo " "
echo "* These audio tracks will be included: \"$langs\""
echo " "
if [ "$suba" = "yes" ]
then
echo "* These subtitles will be included: \"$sub\""
echo " "
fi
if [ "$chang" = "yes" ]
then
echo "* The selected angle is the number \"$target\""
echo " "
fi
echo "* Press Enter key to start!"
read junk


# extracting...
echo "* Extracting cells..."
echo " "
if [ "$suba" = "yes" ]
then
subtitle="-s $sidcount"
else
subtitle=" "
fi
counter=1
echo -n "* Extracting cell number "
bs=$'\b'
for cellz in $cells
do
    echo -n "$cellz"${bs}${bs}
    # the line below was used in the script (until 1.1-rc7) until kernel 2.6.19 was introduced.
    # if this command is used with an earler 2.6.19 version of the kernel,
    # it returns the error "vamps: Fatal: Premature EOF". I don't know why!
#    play_cell -r 0 -g $defaultdvd $vts $pgc $cellz | vamps -E 1 -a $aidcount $subtitle -S 1 > temp$cellz.mpeg

    mkfifo $cellz.fifo
    cat $cellz.fifo | vamps -E 1 -a $aidcount $subtitle -S 1 > temp$cellz.mpeg &
    play_cell -r 0 -g $defaultdvd $vts $pgc $cellz > $cellz.fifo
    rm $cellz.fifo

    size=$( du -b temp$cellz.mpeg | awk -F' ' '{ print $1 }' | perl -pi -e 's/,$//' )
    if [ "$counter" = "1" ]
    then
    filmz=$size
    else
    filmz=$[ $filmz + $size ]
    fi
counter=$( echo "scale=2; $counter + 1 " | bc )
done
echo "...finished!"


# to shrink or not to shrink...
requa=$( echo "scale=2; $filmz / 4600000000 " | bc | perl -pi -e 's/\.//' )
if [ "$requa" -gt "105" ]
then
req=$( echo "scale=2; $filmz / 4600000000 " | bc ) #requant factor
echo " "
echo "* Shrinking needed!"
echo " "
echo "* Requant factor for this movie is: $req"
else
echo " "
echo "* No shrinking needed!"
req="0.9"
fi


# create palette file...
ifo_dump_dvdread $defaultdvd $vts | grep Color | head -n 16 | awk -F' ' '{ print $3 }' > palette.yuv


# create dvdauthor.xml...
echo " "
echo "* Authoring..."
echo "<dvdauthor dest=\"$working/$dvdname/dvd\" >" > dvdauthor.xml
echo "<vmgm />" >> dvdauthor.xml
echo "<titleset>" >> dvdauthor.xml
echo "<titles>" >> dvdauthor.xml
for langz in $langs
do
echo "<audio lang=\"$langz\" />" >> dvdauthor.xml
done
if [ "$suba" = "yes" ]
then
for subz in $sub
do
echo "<subpicture lang=\"$subz\" />" >> dvdauthor.xml
done
subpostorder="-s $subpost "
else
subpostorder=" "
fi
echo "<pgc palette=\"$working/backDvd/palette.yuv\" >" >> dvdauthor.xml
for chapters in $cells
do
	if [ 0$( lsdvd -t $main -c | grep "Cell: $chapters" | awk -F' ' '{ print $7 }' ) = 0$chapters ]
	then
	chpt="chapters=\"0\""
	else
	chpt=" "
	fi
	echo "<vob file=\"vamps -E $req -a $audpostorder $subpostorder &lt; temp$chapters.mpeg |\" $chpt />" >> dvdauthor.xml
done
echo "</pgc>" >> dvdauthor.xml
echo "</titles>" >> dvdauthor.xml
echo "</titleset>" >> dvdauthor.xml
echo "</dvdauthor>" >> dvdauthor.xml


# create dvd structure...
dvdauthor -x dvdauthor.xml 2>/dev/null
dvdauthor -o $working/$dvdname/dvd -T 2>/dev/null


# move to $working and release space...
cd $working
rm -rf backDvd


# preview...
if [ "$preview" = "yes" ]
then
clear
echo "#   backDvd   #"
echo " "
echo -n "* Do you want to preview the dvd (yes/no)? (default no) "
read -e prw
if [ -z "$prw" ]
then 
prw=no
fi
if [ "$prw" = "yes" ]
then
	echo " "
	echo "* Hit enter to preview dvd (CTRL+C to skip, Q to stop preview)"
	echo " "
	read junk
	mplayer dvd://1 -dvd-device $working/$dvdname/dvd >/dev/null 2>&1
fi
fi


# build iso or not...
if [ "$createiso" = yes ]
then
	clear
	echo "#   backDvd   #"
	echo " "
	echo -n "* Do you want to build the .iso file (yes/no)? (default no) "
	 read -e iso
	if [ -z "$iso" ]
	then
	  iso="no"
	fi
else
iso="no"
fi


# build the .iso file...
if [ "$iso" = "yes" ]
then
echo " "
echo "* Building the iso file..."
mkisofs -quiet -dvd-video -V $defaultname -o $working/$dvdname.iso $working/$dvdname/dvd
fi


# burn dvd or not...
if [ "$createiso" = yes ]
then
	clear
	echo "#   backDvd   #"
	echo " "
	echo -n "* Do you want to burn the dvd (yes/no)? (default no) "
	 read -e burn
	if [ -z "$burn" ]
	then
	  burn="no"
	fi
else
burn="no"
fi


# burn dvd...
if [ "$burn" = "yes" ]
then
echo " "
echo -n "* Please insert an empty dvd into the drive and press enter when done..."
read junk
echo " "
echo "* Burning..."
growisofs -quiet -dvd-compat -dvd-video -V $defaultname -Z $defaultdvd  $working/$dvdname/dvd
fi


# Finish...!
clear
echo "#   backDvd   #"
echo " "
echo " "
echo "* The Dvd is located at $working/$dvdname"
echo " "
if [ "$iso" = "yes" ]
then
echo "* dvd iso is located at $working/$dvdname.iso"
echo " "
fi
if [ "$requa" -gt "105" ]
then
echo "* Requant factor for this movie is:" "$req"
echo " "
fi
echo "* Done!"
echo " "
echo "* Enjoy your backup!"
echo " "
Last edited by max-232 on Thu Nov 08, 2007 7:53 am, edited 3 times in total.
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

put it in Gtk2

  • Quote

Post by max-232 » Wed Sep 19, 2007 12:04 pm

Hello all,

I would like to put this script into a gtk2 GUI...
I don't know how to program in C, C++, Python, Tk....anything!!!

some hints?!?! suggestion???
also some "volunteers" that would like to do that?

thanks for answering!
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Wed Sep 19, 2007 5:31 pm

i know a little bit gtk2 perl...
what do i have to do?
is it long to do?(don't know if i will have the time to do it)
by the way i don't know yet:
-> how to do progressbar because sometimes it works fine and sometimes it fails
-> i only know how to pulse the progressbar... because having a true progressbar would need to have a way to calculate the progress(mabe parsing a % in a script)

what i can do:
->popup something when it has finished
->try a pulse progressbar
->input folder or files
->output folder or files
->simplelist(simplified treeview)
->display text
->scroolbar
->talbes
->display a picture in a simplelist
->never done but i can try(i have examples): display the processing in a window
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Wed Sep 19, 2007 5:59 pm

Hello GNUtoo,

thanks for your reply/intrest!

my idea is that: the script that you can see up, can backup dvd...any kind of dvd. but it's a script. I'd like to have a Gtk2 interface. let's say, something like k9copy for kde...but I don't have experience on how to build up an interface, so any other suggestion or idea is welcome!

The first step I suggest you is to try it, to understand what it is and what it does.
Than, any kind of support is welcome! I really don't know where to start, 'cause I don't know any kind of lenguage for programming (I can understand a electronic circuits, music sheets, guitar tabs, and something more but they don't help me in building a gtk2 interface)...

if you're asking yourself why I made another script for backing up dvd, and I don't use an existing program, this is the answer:
1. I use gnome and I don't wan't to install Qt libraries, 'cause I find Gtk interface better and lightweghter than Qt's/Kde's;
2. Existing programs doesn't use vamps for backup (that is the BEST!!!), except k9copy but this is in cintrast with the above point;
3. My script can manage audio tracks, and reorder them;
4. My script can manage subtitle tracks, and reorder them;
5. My script can let you select between multiple angles which to backup
6. My script shows you the "longest traks" and not the "longest track", which is one of the more stupid but efficient why to protect dvd from backing them up.
7. I find usefull to build an interface to let other people use it.

after that, I'd say you (and others!) that if you want to help me you're welcome!
if you don't want or if you don't think of beeing able, don't worry, it's the same, and you're welcome the same! :)

anyway,

thanks!
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Wed Sep 19, 2007 6:16 pm

first i won't be able to do what k3b is doing but i can do something simplier...
an example of what i've done is gkp:

Code: Select all

#!/usr/bin/perl -w
#This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA 
use strict ;
use Gtk2 '-init' ;
use Gtk2::Helper;
use Glib qw(TRUE FALSE);
use Time::HiRes qw(usleep);
use FileHandle;

our $filename;
our $save_as;
our $progressbar;
our $manual;

sub quit{
Gtk2->main_quit;
}

sub destroy_manual {
$manual->destroy();
}

sub progressbar {
Gtk2->main_iteration while Gtk2->events_pending;
# $progressbar->set_pulse_step(0.1 ) ;
$progressbar->pulse;
# usleep(100000);
}


sub manual {
my $manual = Gtk2::Dialog->new ('HOWto use this software', undef,'destroy-with-parent');
my $manual_label = Gtk2::Label->new("*insert your dvd\n *read it with your favorite dvd software\n *run this software");
$manual->vbox->add ($manual_label);
$manual->signal_connect (response => \&destroy_manual );
$manual->show_all;
}

sub finished {
my $finished = Gtk2::Dialog->new ('The extraction has finished', undef,'destroy-with-parent',				                                                'ok' => '4');
my $label = Gtk2::Label->new("point k9copy to the dvd folder that you can find in this folder: $save_as");
$finished->vbox->add ($label);
$finished->signal_connect (response => \&quit );
$finished->show_all;
$finished->signal_connect (response => \&button_response );
}

sub file_saver {
my $dialog = Gtk2::FileChooserDialog->new('Save as',undef,'save',
                                          'gtk-ok', 'ok',
                                          'gtk-cancel', 'cancel');
$dialog->set_action('select-folder');
my $response = $dialog->run(); # this blocks

if ($response eq 'ok') {
    $save_as = $dialog->get_filename();
}

$dialog->destroy();

}

my $main_app_window;
my $dialog = Gtk2::Dialog->new ('gkp: dvd extractor', $main_app_window,
                                'destroy-with-parent',
				"Destination of the video" => '1' ,
				"extract" => '2',
				"manual" => '3',
				"progressbar test" => '5'
				);

         $dialog->signal_connect (response => \&button_response );
	 $dialog->signal_connect(delete_event => \&quit);

$progressbar = Gtk2::ProgressBar->new;
$dialog->vbox->add ($progressbar);

sub button_response { 
my ($dialog, $response_id) = @_;

if ($response_id eq '1') { 
file_saver();
}

if ($response_id eq '2') { 
my $pipe = FileHandle->new;
open $pipe, '-|', "deadreader /dev/cdrom /tmp/dvd.iso && mount /tmp/dvd.iso && cd $save_as && vobcopy -m -i /mnt/cdrom && rm /tmp/dvd.iso && rm /tmp/dvd.iso.smap" or die "can't do the processing";

my $watch;
$watch = Gtk2::Helper->add_watch ( $pipe->fileno, 'in', sub {
           watcher_callback( $pipe, $watch );
         });
sub watcher_callback {
             my ($pipe, $watch) = @_;

             # we safely can read a chunk into $buffer
             my $buffer;

             if ( not sysread($pipe, $buffer, 4096) ) {
               # obviously the connected pipe was closed
             			finished();
				Gtk2::Helper->remove_watch ($watch) or die "couldn't remove watcher";
               			close($pipe);
               return 1;
             }

             # do something with $buffer ...
             print $buffer;
# 	     progressbar();
	     $progressbar->{timer} = Glib::Timeout->add(1000, \&progressbar, $progressbar);

             # *always* return true
             return 1;
         }



}
if ($response_id eq '3') { 
manual();
}

if ($response_id eq '4') { 
quit();
}



if ($response_id eq '5') {

$progressbar->{timer} = Glib::Timeout->add(100, \&progressbar, $progressbar);
}

}


$dialog->show_all;
Gtk2->main;
return 0
how do you get arguments in bash?
because it would be easyer for me or someone else to do the gui if you can pass arguments to the program:

for instance here you have the line:

Code: Select all

open $pipe, '-|', "deadreader /dev/cdrom /tmp/dvd.iso && mount /tmp/dvd.iso && cd $save_as && vobcopy -m -i /mnt/cdrom && rm /tmp/dvd.iso && rm /tmp/dvd.iso.smap" or die "can't do the processing";
that's how it works...you give dynamic arguments...
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Wed Sep 19, 2007 6:27 pm

lol max-232 is a chip for converting to 5v no?
i was a lot in electronics before i switched to free software
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Wed Sep 19, 2007 7:14 pm

hey some story here!
I was in electronics a lot until my job wanted me to intrest in software. There one of my collegues, showed me linux, BSD, open source & free sw.
so, max-232 was the chip I ned for my first circuit board: a circuit to interface the nokia 3210/3310/3300 to the serial port!

ok, back to the sw! :)

I'm building some perl modules to see how your program looks! ;)

I'm italian and my english understanding/writing is quite bad, so, please be patient!
what do you mean with "how do you get arguments in bash?"?

if I've understood well, you mean how i put parameters into the script, right?
so, if this is the question, the script start normally (for instance: without any flags) and it just analyze the dvd and ask you some question that you have to answer.
at the end of the question it shows a recap and then it starts to work.
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Wed Sep 19, 2007 7:24 pm

max-232 wrote:hey some story here!
I was in electronics a lot until my job wanted me to intrest in software. There one of my collegues, showed me linux, BSD, open source & free sw.
so, max-232 was the chip I ned for my first circuit board: a circuit to interface the nokia 3210/3310/3300 to the serial port!

ok, back to the sw! :)

I'm building some perl modules to see how your program looks! ;)

I'm italian and my english understanding/writing is quite bad, so, please be patient!
what do you mean with "how do you get arguments in bash?"?

if I've understood well, you mean how i put parameters into the script, right?
so, if this is the question, the script start normally (for instance: without any flags) and it just analyze the dvd and ask you some question that you have to answer.
at the end of the question it shows a recap and then it starts to work.
hey you're from italy...i'm mooving to milan...
what i mean as parameters is like that:

Code: Select all

tar -xvjpf file.tar.bx2
-xvjpf and file.tar.bz2 are the parameters
rather than asking question...put them into parameters...and remove the quesions
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Wed Sep 19, 2007 7:34 pm

parameters....I have to work on....because, for example, it analyzes how many (and which) audio tracks there are on the video track you've selected to backup and then it ask you which one (or two, or three....) you want to backup....
I have to work on that, you're right!

hey, i've ended to compile the perl modules, your script looks really great!
I'll take a look at the code later or tomorrow (now I'm really in late and my girlfriend could become gelous of my computer...and it's not so good!).

I have to go now, let's keep in touch (tomorrow or day after)!

for the moment THANKS A LOT!!!!

have a nice evening!

ciao
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Wed Sep 19, 2007 7:35 pm

I'm italian and my english understanding/writing is quite bad, so, please be patient!
so what's your native language?
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Wed Sep 19, 2007 7:44 pm

as i am mooving to milan i don't know for how many time i won't have an internet connection
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Wed Sep 19, 2007 9:36 pm

GNUtoo wrote:
I'm italian and my english understanding/writing is quite bad, so, please be patient!
so what's your native language?
My native language is italian. I know a bit of english 'cause of my job needs it from me. :)
GNUtoo wrote:as i am mooving to milan i don't know for how many time i won't have an internet connection
no problem, take your time! ...from time to time I have to come to Milan for work...but not in the coming days...

anyway, thanks for your support!

PS: Enjoy Italy!

ciao!
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Sun Sep 23, 2007 2:20 pm

max-232 wrote:
GNUtoo wrote:
I'm italian and my english understanding/writing is quite bad, so, please be patient!
so what's your native language?
My native language is italian. I know a bit of english 'cause of my job needs it from me. :)
GNUtoo wrote:as i am mooving to milan i don't know for how many time i won't have an internet connection
no problem, take your time! ...from time to time I have to come to Milan for work...but not in the coming days...

anyway, thanks for your support!

PS: Enjoy Italy!

ciao!
oops i read my italian and my english and not i'm italian...lol
Top
GNUtoo
Veteran
Veteran
User avatar
Posts: 1919
Joined: Thu May 05, 2005 9:39 pm

  • Quote

Post by GNUtoo » Sun Sep 23, 2007 2:26 pm

change

Code: Select all

echo -n "* What shall we call it? (default $defaultname): "
to make it more clear that it's the dvd on your hdd that you want to name

by the way i do not have any dvd for testing...yet so you'll have to wait
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Mon Sep 24, 2007 5:16 pm

change
Code:
echo -n "* What shall we call it? (default $defaultname): "

to make it more clear that it's the dvd on your hdd that you want to name

by the way i do not have any dvd for testing...yet so you'll have to wait
hi GNUtoo,

thanks for the tip, I'll change it as you suggest! np for waiting....it's a lot of time that I made the script...so I can also wait a lot for the interface...
I took a look again to your gtk2-perl script...and when I'll have a bit of time, I think I'll search for some documentation to learn more of this language...it seems to be quite simple and usable for this simple kind of things.
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

backDvd-1.1_rc9.sh

  • Quote

Post by max-232 » Wed Oct 31, 2007 10:53 pm

Hi all,
I'm pleased to post here a new version, more powerful, feature-reach, and bug-free (at least I hope) of backDvd!!!

CHANGELOG: Automatic angle managing (it just suggests the best angle according to the first audio language), ability to go over the latest DVD anti-copy protection, a bit more user-friendly...and much more is coming soon (with a bit of luck, also a GTK frontend!)!!!

Please enjoy the new version of backDvd (tested also in others distros!!!), and report me any kind of bug...or feature that you whish to see in next release!!!

Code: Select all

#!/bin/bash
#
# to use backDvd you need: libdvdread vamps lsdvd dvdauthor ifo_dump
# optional: cdrtools
#
# All is born here http://forums.gentoo.org/viewtopic-t-457186.html
# Thanks a lot to ~L~ and his halkase script. I've copied the structure of backDvd from halkase.


# let's start!
clear
echo " "
echo "########################################################################"
echo "#                                                                      #"
echo "#                        This is backDvd 1.1 rc9                       #"
echo "#                                                                      #"
echo "#      A script for backing up DVD9 main title to DVD5 - by yknuk      #"
echo "#                                                                      #"
echo "#         This software is distributed under the GNU GPL terms.        #"
echo "#                                                                      #"
echo "#                 Use this software at your own risk!                  #"
echo "#             backDvd comes with absolutely NO WARRANTY!               #"
echo "#               Don't blame me if your PC get crashed!                 #"
echo "#                                                                      #"
echo "########################################################################"
echo " "
echo " "
echo "* Welcome to backDvd! Press Enter key to start! (CTRL+C to exit)"
read junk


# check programs...
clear
echo "#   backDvd   #"
echo " "
echo "* Checking for the minimal programs/libraries requirements..."
echo " "


        # checking for vamps...
        if [ ! -f "/usr/bin/vamps" ]
        then
	check=yes
        echo "* !!! You don't have vamps-0.99.2 installed... please provide!"
	echo " "
        fi


        # checking for play_cell...
        if [ ! -f "/usr/bin/play_cell" ]
        then
	check=yes
        echo "* !!! You don't have play_cell (vamps-0.99.2) installed... please provide!"
        echo " "
        fi


        # checking for libdvdread...
        if [ ! -f "/usr/lib/libdvdread.so" ]
        then
	check=yes
        echo "* !!! You don't have libdvdread installed... please provide!"
        echo " "
        fi


        # checking for ifo_dump...
	ifodump=$( ls /usr/bin/ | grep ifo_dump | awk -F' ' '{print $1}' )
        if [ -z $ifodump ]
        then
	check=yes
        echo "* !!! You don't have ifo_dump installed... please provide!"
	echo "* !!! Some distros (i.e. Debian based) have ifo_dump in the ogle-mmx package."
	echo "* !!! For other distros (like Gentoo) it's in libdvdread (>=0.9.6)."
        echo " "
        fi


        # checking for lsdvd...
        if [ ! -f "/usr/bin/lsdvd" ]
        then
	check=yes
        echo "* !!! You don't have lsdvd installed... please provide!"
        echo " "
        fi


        # checking for dvdauthor...
        if [ ! -f "/usr/bin/dvdauthor" ]
        then
	check=yes
        echo "* !!! You don't have dvdauthor installed... please provide!"
        echo " "
        fi


	# check results
	if [ "$check" = "yes" ]
	then
	exit
	fi
	

        # checking for cdrtools (mkisofs)...
        if [ ! -f "/usr/bin/mkisofs" ]
        then
		echo "* !!! You don't have cdrtools installed!"
		echo "* !!! If you continue you'll not able to create the iso file and/or burn the dvd!"
		echo -n "* !!! Do you want to continue? (yes/no) "
		 read -e isofs
		if [ "$isofs" = "yes" ]
		then
		  createiso="no"
		else
		exit
		fi
        else
        createiso="yes"
        fi


# change that for meet your defaults...
home=~
#home="/home/backup"
defaultworkingdir="$home/film-dvd"
defaultdvd="/dev/dvd"


        # go to the working directory...
	clear
	echo "#   backDvd   #"
	echo " "
        echo -n "* What is your working directory? (default: $defaultworkingdir) "
         read -e workingdir
        if [ -z "$workingdir" ]
        then
          workingdir="$defaultworkingdir"
        fi


        # check the default working dir...
        if [ ! -d "$workingdir" ]
	then
	clear
	echo "#   backDvd   #"
	echo " "
        echo "* The default working directory ($workingdir) doesn't exists!"
	echo " "
        echo -n "* Do you want to create it? (default: yes) "
         read -e crworking
        if [ -z "$crworking" ]
	then
	crworking=yes
	fi
	if [ "$crworking" = "yes" ]
	then
	echo " "
        echo "* Creating directory $workingdir"
        mkdir -p $workingdir
	else
	exit
	fi
        fi


        # check for enough space...
	freespace=$( df -k $workingdir | tail -n +2 | head -n 1 | awk -F' ' '{print $4}' )
        if [ "$freespace" -lt "10000000" ]
	then
	gfreespace=$(df -h $workingdir | tail -n +2 | head -n 1 | awk -F' ' '{print $4}')
	echo " "
        echo "* !!! You don't have enough space on the selected working folder."
	echo "* !!! You should have at least 10G of free space. Please provide and try again."
	echo "* !!! Actual free space is about $gfreespace."
        exit
        fi


        # enter working dir...
	cd $workingdir
	if [ -d backDvd ]
	then
	echo " "
	echo "* Cleaning backDvd dir..."
	rm -rf backDvd
	fi
	mkdir backDvd
        cd backDvd


# where to read...
clear
echo "#   backDvd   #"
echo " "
echo -n "* Where is your dvd device? (default: $defaultdvd) "
 read -e device
if [ -z "$device" ]
then
  device="$defaultdvd"
fi


# grab dvd name...
defaultname=$( lsdvd $device | head -n 1 | tail -n 1 | awk -F' ' '{ print $3 }' )


# title name...
clear
echo "#   backDvd   #"
echo " "
echo -n "* What shall we call it? (default: $defaultname) "
 read -e dvdname
if [ -z "$dvdname" ]
then
  dvdname="$defaultname"
fi
	if [ -d $workingdir/$dvdname ]
	then
	echo " "
	echo "* A folder with the name \"$dvdname\" already exists!"
	echo " "
	echo -n "* I must DELETE it!!! Continue (yes/no)? (default: no) "
	 read -e delete
		if [ "$delete" = "yes" ]
		then
		rm -rf $workingdir/$dvdname
		echo "* Folder Deleted. continuing..."
		else
		exit
		fi
	fi
echo " "
mkdir $workingdir/$dvdname


# what's in the dvd...
longest=$( lsdvd $device | grep "Longest track:" | awk -F' ' '{ print $3 }' )
clear
echo "#   backDvd   #"
echo " "
echo "* These are the longest title/s on the dvd:"
echo " "
lsdvd $device | grep -v "Length: 00" | grep -v Disc | grep -v Longest | grep " "
echo " "


# which title to backup...
echo -n "* Which one do you want to backup? (default: $longest) "
read -e main
if [ -z "$main" ]
then
  main=$longest
fi
main=$( echo "$main" | bc )


# generate pgc and vts
#pgc=$( title_info $device | grep -A 1 "Title $main:" | grep TTN | awk -F' ' '{ print $5}' | perl -pi -e 's/]$//' )
#vts=$( title_info $device | grep -A 1 "Title $main:" | grep VTS | awk -F' ' '{ print $3}' )
pgc=$( ifo_dump_dvdread $device 0 | grep -A 1 "Title Track index $main" | head -n 2 | grep VTS | awk -F' ' '{print $7}' )
vts=$( ifo_dump_dvdread $device 0 | grep -A 1 "Title Track index $main" | head -n 2 | grep VTS | awk -F' ' '{print $5}' )


# and then audio...
clear
echo "#   backDvd   #"
echo " "
echo "* These are the audio track for the titles $main: "
echo " "
lsdvd $device -t $main -a | grep Audio: | awk -F' ' '{ print $2,$5,$6,$5,$13,$14,$5,$8 }' | perl -pi -e 's/,//g'
echo " "
echo -n "* How many audio tracks do you want to backup? (default: 1) "
read -e numaud
if [ -z "$numaud" ]
then
numaud=1
fi
numaudplus=$[ 1 + $numaud ]
counter=1
while [  $counter -lt $numaudplus ]; do
echo -n "* Which language do you want to be the number $counter of $numaud? (example: 1) "
read -e aidz
if [ -z "$aidz" ]
then
echo " "
echo "* You have to select the language, not just press enter! exiting..."
exit
fi
language=$( lsdvd $device -t $main -a | grep "Audio: $aidz" |  awk -F' ' '{ print $4 }' )
if [ "$counter" = "1" ]
then
audpostorder="$counter"
aidcount="$aidz"
langs="$language"
else
audpostorder="$audpostorder,$counter"
aidcount="$aidcount,$aidz"
langs="$langs $language"
fi
counter=$( echo "scale=2; $counter + 1 " | bc )
done


# and the subtitles...
clear
echo "#   backDvd   #"
echo " "
echo -n "* Do you want to add subtitle tracks on your backup (yes/no)? (default: no) "
read -e suba
if [ -z "$suba" ]
then
suba="no"
fi
if [ "$suba" = "yes" ]
then
echo " "
echo "* These are the avilable subtitles for the title $main:"
echo " "

lsdvd $device -t $main -s | grep Subtitle: | awk -F' ' '{ print $2,$5,$6 }' | perl -pi -e 's/,//g' | perl -pi -e 's/^0//g'
# this line above is an alternative to the lines below
#nr_of_st=$( $ifodump $device $vts | grep "VTS Number of Subpicture attributes:"| awk -F' ' '{print $6}' )
#$ifodump $device $vts | grep -A $nr_of_st "VTS Number of Subpicture attributes:" | awk -F ' ' '{print 0$2+1,"-",$7,"-",$11,$12,$13,$14,$15,$16,$17 }' | tail -n 12 | head -n 9 
#$ifodump $device $vts | grep -A $nr_of_st "VTS Number of Subpicture attributes:" | awk -F ' ' '{print $2+1,"-",$7,"-",$11,$12,$13,$14,$15,$16,$17 }' | tail -n $( echo 12-9 | bc)

echo " "
echo -n "* How many subtitles do you want to backup? (default: 1) "
read -e numsub
if [ -z "$numsub" ]
then
numsub=1
fi
numsubplus=$[ 1 + $numsub ]
counter=1
while [  $counter -lt $numsubplus ]; do
echo -n "* Which subtitle do you want to be the number $counter of $numsub? (example: 1) "
read -e nub
if [ -z "$nub" ]
then
echo " "
echo "* You have to select the subtitle, not just press enter! exiting..."
exit
fi
if [ $nub -lt 10 ]
then
nub=0$nub
fi
nubact=$(echo "ibase=16; $( $ifodump $device $vts | grep "Subpicture stream " | grep "`echo \"$nub-1\" | bc` control: " | head -n 1 | awk -F' ' '{print $5}' | cut -c 5,6 | tr a-z A-Z )" +1 | bc)
nubz=$( lsdvd $device -t $main -s | grep "Subtitle: $nub" | awk -F' ' '{ print $4 }' )
if [ "$counter" = "1" ]
then
subpost="$counter"
sidcount="$nubact"
sub="$nubz"
else
subpost="$subpost,$counter"
sidcount="$sidcount,$nubact"
sub="$sub $nubz"
fi
counter=$( echo "scale=2; $counter + 1 " | bc )
done
echo " "
fi


# angles...
ang=$( lsdvd $device -t $main -n 2>/dev/null | grep "Angles: " | awk -F' ' '{ print $4 }' )
if [ "$ang" = "1" ]
then
target=$ang
else
chang=yes
suggested_ang=$( echo $aidcount | awk -F',' '{print $1}' )
if [ "$suggested_ang" = "2" ]
then
suggestedang=2
else
suggestedang=1
fi
secondang=$( lsdvd $device -t $main -a 2>/dev/null | grep "Audio: 2" | awk -F', Language: ' '{print $2}' | awk -F', Format:' '{print $1}' )
clear
echo "#   backDvd   #"
echo " "
echo "* There are $ang angles for this title."
echo " "
echo "* Please note that for some films you have 2 angles"
echo "* because of different lenguages; for displaying"
echo "* differented images during the film, depending on"
echo "* the audio language you are listening to."
echo "* If this is the case, normally the first audio"
echo "* language is accorded to the first angle language."
echo " "
echo "* i.e.: first language english, first angle english."
echo "* In this dvd the 2nd language is \"$secondang\"."
echo " "
echo -n "* Wich one do you want to keep? (suggested: $suggestedang) "
read -e target
if [ -z "$target" ]
then
target=$suggestedang
fi
if [ "$target" -gt "$ang" ]
then
	clear
	echo "#   backDvd   #"
	echo " "
	echo "* !!! Wrong angle selected! Exiting..."
	exit
fi
if [ "$target" -lt "1" ]
then
	clear
	echo "#   backDvd   #"
	echo " "
	echo "* !!! Wrong angle selected! Exiting..."
	exit
fi
fi


# generate cell list...
echo " "
echo "* Retrieving cell list from DVD..."
cells=$( lsdvd $device -t $main -d | grep Cell: | awk -F' ' '{ print $2 }' | perl -pi -e 's/\n//' | perl -pi -e 's/,/ /g' )


# regenerate $cells angle-compliant, if needed...
if [ "$ang" -gt "1" ]
then
dangl=$( $ifodump $device $vts | grep "block angle" | grep "first" | awk -F' ' '{ print $2 }' )
if [ "$target" -ne "1" ]
then
chptrescue="-1"
count1=1
count2=1
while [ "$count1" -le "$ang" ]; do
	if [ "$count1" -ne "$target" ]
	then
		if [ "$count2" -eq "1" ]
		then
		dellist=$( echo "$dangl" )
		count2=$( echo "scale=2; $count2 + 1 " | bc )
		else
		dellist=$( echo "$dellist" $'\n' "$dangl" )
		fi
	dangl=$( echo "$dangl" | awk -F' ' '{ print $1"+1" }' | bc )
	fi
count1=$( echo "scale=2; $count1 + 1 " | bc )
done
else
chptrescue="+1"
count1=1
count2=1
while [ "$count1" -le "$ang" ]; do
	if [ "$count1" -ne "$target" ]
	then
		if [ "$count2" -eq "1" ]
		then
		dangl=$( echo "$dangl" | awk -F' ' '{ print $1"+1" }' | bc )
		dellist=$( echo "$dangl" )
		count2=$( echo "scale=2; $count2 + 1 " | bc )
		else
		dangl=$( echo "$dangl" | awk -F' ' '{ print $1"+1" }' | bc )
		dellist=$( echo "$dellist" $'\n' "$dangl" )
		fi
	fi
count1=$( echo "scale=2; $count1 + 1 " | bc )
done
fi
dellist=$( echo $dellist )
cells=$( echo $cells | perl -pi -e 's/\s+/\n/g' )
for x in $dellist
do
	if [ $x -lt 10 ]
	then 
	y="0$x"
	cells=$(echo "$cells" | grep -v "$y")
	else
	cells=$(echo "$cells" | grep -v "$x")
	fi
done
cells=$( echo $cells )
fi


# build iso or not...
if [ "$createiso" = yes ]
then
	clear
	echo "#   backDvd   #"
	echo " "
	echo -n "* Do you want to build the .iso file (yes/no)? (default: no) "
	 read -e iso
	if [ -z "$iso" ]
	then
	  iso="no"
	fi
else
iso="no"
fi
if [ "$iso" = yes ]
then
	if [ -f $workingdir/$dvdname.iso ]
	then
	echo " "
	echo "* An iso with the name \"$dvdname.iso\" already exists!"
	echo " "
	echo -n "* I must DELETE it!!! Continue (yes/no)? (default: no) "
	 read -e delete
		if [ "$delete" = "yes" ]
		then
		rm -rf "$workingdir/$dvdname.iso"
		echo "* File Deleted. continuing..."
		else
		exit
		fi
	fi
fi


# burn dvd or not...
if [ "$createiso" = yes ]
then
	clear
	echo "#   backDvd   #"
	echo " "
	echo -n "* Do you want to burn the dvd (yes/no)? (default: no) "
	 read -e burn
	if [ -z "$burn" ]
	then
	  burn="no"
	fi
else
burn="no"
fi


# recap...
clear
echo "#   backDvd   #"
echo " "
echo "* These audio tracks will be included: \"$langs\""
echo " "
if [ "$suba" = "yes" ]
then
echo "* These subtitles will be included: \"$sub\""
echo " "
fi
if [ "$chang" = "yes" ]
then
echo "* The selected angle is the number \"$target\""
echo " "
fi
if [ "$iso" = "yes" ]
then
echo "* The .iso file will be built"
echo " "
fi
if [ "$burn" = "yes" ]
then
echo "* The dvd will be burnt. You'll be prompted later to load an empty dvd."
echo " "
fi
echo "* Press Enter key to start!"
read junk


# extracting...
echo "* Extracting cells..."
echo " "
if [ "$suba" = "yes" ]
then
subtitle="-s $sidcount"
else
subtitle=" "
fi
counter=1
echo -n "* Extracting cell number "
bs=$'\b'
for cellz in $cells
do
    if [ "$cellz" -lt "100" ]
    then
    echo -n "$cellz"${bs}${bs}
    else
    echo -n "$cellz"${bs}${bs}${bs}
    fi
    # the line below was used in the script (until 1.1-rc7) until kernel 2.6.19 was introduced.
    # if this command is used with an earler 2.6.19 version of the kernel,
    # it returns the error "vamps: Fatal: Premature EOF". I don't know why!
#    play_cell -r 0 -g $device $vts $pgc $cellz | vamps -E 1 -a $aidcount $subtitle -S 1 > temp$cellz.mpeg

    mkfifo $cellz.fifo
    cat $cellz.fifo | vamps -E 1 -a $aidcount $subtitle -S 1 > temp$cellz.mpeg &
    play_cell -r 0 -g $device $vts $pgc $cellz > $cellz.fifo
    rm $cellz.fifo

    size=$( du -b temp$cellz.mpeg | awk -F' ' '{ print $1 }' | perl -pi -e 's/,$//' )
    if [ "$counter" = "1" ]
    then
    filmz=$size
    else
    filmz=$[ $filmz + $size ]
    fi
counter=$( echo "scale=2; $counter + 1 " | bc )
done
echo "...finished!"


# to shrink or not to shrink...
requa=$( echo "scale=2; $filmz / 4600000000 " | bc | perl -pi -e 's/\.//' )
if [ "$requa" -gt "105" ]
then
req=$( echo "scale=2; $filmz / 4600000000 " | bc ) #requant factor
echo " "
echo "* Shrinking needed!"
echo " "
echo "* Requant factor for this movie is: $req"
else
echo " "
echo "* No shrinking needed!"
req="1"
fi


# create palette file...
$ifodump $device $vts | grep Color | head -n 16 | awk -F' ' '{ print $3 }' > palette.yuv


# get video settings
got_format=$( lsdvd $device -t $main -v | grep "Format: " | awk -F'Format: ' '{ print $2 }' |awk -F', Aspect ' '{ print $1 }' )
got_aspect=$( lsdvd $device -t $main -v | grep "Format: " | awk -F'Aspect ratio: ' '{ print $2 }' |awk -F', Width' '{ print $1 }' )
got_widescreen=$( lsdvd $device -t $main -v | grep "DF: " | awk -F'DF: ' '{ print $2 }' )
if [ "$got_format" = "PAL" ]
	then
	format=$( echo format=\"pal\" )
	else
	if [ "$got_format" = "NTSC" ]
		then
		format=$( echo format=\"ntsc\" )
	fi
fi
if [ "$got_aspect" = "16/9" ]
	then
	aspect=$( echo aspect=\"16:9\" )
	else
	if [ "$got_aspect" = "4/3" ]
		then
		aspect=$( echo aspect=\"4:3\" )
	fi
fi
if [ "$got_widescreen" = "Letterbox" ]
	then
	widescreen=$( echo widescreen=\"nopanscan\" )
	else
	if [ "$got_widescreen" = "P&S" ]
		then
		widescreen=$( echo widescreen=\"noletterbox\" )
		else
		if [ "$got_widescreen" = "P&S + Letter" ]
			then
			widescreen=$( echo " " )
			else
			rapp=$( echo "scale=2; $(lsdvd $device -t $main -v| grep Width | awk -F'Width: ' '{print $2}' | awk -F', Height: ' '{print $1}')/$(lsdvd $device -t $main -v| grep Width | awk -F'Height: ' '{print $2}' | awk -F', DF: ' '{print $1}')" | bc )
			if [ "$rapp" = "1.25" ]
			then
			widescreen=$( echo widescreen=\"nopanscan\" )
			fi
		fi	
	fi
fi
if [ ! -z "$format" ]
then
vid_dvdauth_opts=$format
fi
if [ ! -z "$aspect" ]
then
vid_dvdauth_opts="$vid_dvdauth_opts $aspect"
fi
if [ ! -z "$widescreen" ]
then
vid_dvdauth_opts="$vid_dvdauth_opts $widescreen"
fi


# create dvdauthor.xml...
all_chpts=$( lsdvd $device -t $main -c | grep "Cell: " | awk -F' ' '{ print $7 }' )

for x in $dellist
do
dellist2=$(echo "$all_chpts" | grep "$x")
dellistnew="$dellistnew $dellist2"
done
dellistnew=$( echo $dellistnew )

echo " "
echo "* Authoring..."
echo "<dvdauthor dest=\"$workingdir/$dvdname/dvd\" >" > dvdauthor.xml
echo "<vmgm />" >> dvdauthor.xml
echo "<titleset>" >> dvdauthor.xml
echo "<titles>" >> dvdauthor.xml
if [ ! -z "$vid_dvdauth_opts" ]
then
echo "<video $vid_dvdauth_opts />" >> dvdauthor.xml
fi
for langz in $langs
do
echo "<audio lang=\"$langz\" />" >> dvdauthor.xml
done
if [ "$suba" = "yes" ]
then
for subz in $sub
do
echo "<subpicture lang=\"$subz\" />" >> dvdauthor.xml
done
subpostorder="-s $subpost "
else
subpostorder=" "
fi
echo "<pgc palette=\"$workingdir/backDvd/palette.yuv\" >" >> dvdauthor.xml
for chapters in $cells
do
	if [ 0$( echo $all_chpts | perl -pi -e 's/ /\n/g' | grep $chapters ) = 0$chapters ]
	then
	chpt="chapters=\"0\""
	else
		chpthid=$( echo "$chapters$chptrescue" | bc )
	        if [ $chpthid -lt 10 ]
	        then
		chpthid=0$chpthid
		fi
		if [ 0$( echo $dellistnew | perl -pi -e 's/\s+/\n/g' | grep $chpthid ) = 0$chpthid ]
		then
		chpt="chapters=\"0\""
		else
		chpt=" "
		fi
	fi
	echo "<vob file=\"vamps -E $req -a $audpostorder $subpostorder &lt; temp$chapters.mpeg |\" $chpt />" >> dvdauthor.xml
done
echo "</pgc>" >> dvdauthor.xml
echo "</titles>" >> dvdauthor.xml
echo "</titleset>" >> dvdauthor.xml
echo "</dvdauthor>" >> dvdauthor.xml


# create dvd structure...
dvdauthor -x dvdauthor.xml 2>/dev/null
dvdauthor -o $workingdir/$dvdname/dvd -T 2>/dev/null


# move to $workingdir and release space...
cd $workingdir
rm -rf backDvd


# build the .iso file...
if [ "$iso" = "yes" ]
then
echo " "
echo "* Building the iso file..."
mkisofs -quiet -dvd-video -V $dvdname -o $workingdir/$dvdname.iso $workingdir/$dvdname/dvd
fi


# burn dvd...
if [ "$burn" = "yes" ]
then
echo " "
echo -n "* Please insert an empty dvd into the drive and press enter when done..."
read junk
echo " "
echo "* Burning..."
growisofs -quiet -dvd-compat -dvd-video -V $dvdname -Z $device  $workingdir/$dvdname/dvd
fi


# Finish...!
clear
echo "#   backDvd   #"
echo " "
echo " "
echo "* The Dvd is located at $workingdir/$dvdname/dvd"
echo " "
if [ "$iso" = "yes" ]
then
echo "* dvd iso is located at $workingdir/$dvdname.iso"
echo " "
fi
if [ "$requa" -gt "105" ]
then
echo "* Requant factor for this movie is:" "$req"
echo " "
fi
echo "* Done!"
echo " "
echo "* Enjoy your backup!"
echo " "
Last edited by max-232 on Tue Nov 06, 2007 7:31 am, edited 1 time in total.
Top
Schizoid
Apprentice
Apprentice
Posts: 267
Joined: Fri Apr 11, 2003 12:54 am

  • Quote

Post by Schizoid » Mon Nov 05, 2007 11:29 pm

I just wanted to say that I just used this and it seems to have worked beautifully.

Thank you very much!
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Tue Nov 06, 2007 10:59 pm

Thanks to you!
I'm glad to see that I have build something useful for others! ;)

Just a little note: if you, or someone else, have suggestions/bugs/"whishlist" for backDvd, please just post here or contact me! I'll be happy to have your help!

Thanks

Massimo
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

backDvd 1.1

  • Quote

Post by max-232 » Thu Nov 08, 2007 7:54 am

backDvd 1.1 released here http://www.cli-apps.org/content/show.ph ... tent=69322
Top
yabbadabbadont
Advocate
Advocate
User avatar
Posts: 4791
Joined: Fri Mar 14, 2003 12:02 am
Location: 2 exits past crazy

  • Quote

Post by yabbadabbadont » Thu Nov 08, 2007 8:23 am

After just a quick look at the script, might I suggest that you don't hard-code the paths in which you expect to find the needed utilities. Those are the standard locations on Gentoo, but on other systems the users may have them in /usr/local/bin, /usr/local/lib, ... For the executables, you might try using "which" to see if they are located somewhere in the user's PATH. I'm not sure how you would handle the libraries though. Once I've had a chance to look through it more thoroughly and play with it, I might come up with another suggestion. I'll let you know if I do.

By the way, thanks for making the script in the first place. It is always better to have more options rather than fewer. (In my opinion at least :))

Edit: You probably should properly quote all of your file name and directory name containing variables so that embedded spaces and special characters will be handled correctly. (otherwise you'll probably get some hate mail the first time the script "rm -rf somedir withspace" and it wipes out the wrong stuff... ;))
Bones McCracker wrote:On the other hand, regex is popular with the ladies.
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Thu Nov 08, 2007 10:43 pm

Thanks for your reply!
and thanks a lot for your precious suggestion! I've "applied them", but instead of using which I've used whereis!
Thanks also for the "rm -rf" suggestion, I've also "added" a way to manage the ~ character (at least it seems to work!) and other minor bug fixed and minor features (that can be found in the ChangeLog file)!

A new minor release has been released!

Say hello to backDvd-1.1.1!!

Any other suggestion would be appreciated!

Thanks!
Top
yabbadabbadont
Advocate
Advocate
User avatar
Posts: 4791
Joined: Fri Mar 14, 2003 12:02 am
Location: 2 exits past crazy

  • Quote

Post by yabbadabbadont » Thu Nov 08, 2007 11:11 pm

whereis doesn't, by default, search the invoking user's path. which does.

Code: Select all

/home/daffy $ whereis fluxbox-generate_menu
fluxbox-generate_menu: /usr/bin/fluxbox-generate_menu /usr/X11R6/bin/fluxbox-generate_menu
/home/daffy $ whereis fluxbox-generate_menu-hacked
fluxbox-generate_menu-hacked:
/home/daffy $ l bin
total 136
-rwxr-xr-x 1 daffy users   192 2007-11-02 20:09 calendar-display*
-rwxr-xr-x 1 daffy users 66519 2007-11-05 20:02 fluxbox-generate_menu-hacked*
-rwxr-xr-x 1 daffy users 39298 2007-11-05 20:03 generate-openbox-menu*
-rwxr-xr-x 1 daffy users    87 2007-10-21 19:44 grab-screen*
-rwxr-xr-x 1 daffy users    79 2007-10-21 19:44 grab-selection*
-rwxr-xr-x 1 daffy users  1870 2007-08-01 06:02 veoh-dl*
-rwxr-xr-x 1 daffy users  4201 2007-10-30 20:04 wallmenu.py*
/home/daffy $ which fluxbox-generate_menu-hacked 
/home/daffy/bin/fluxbox-generate_menu-hacked
/home/daffy $ echo $PATH
/home/daffy/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.1.2:/usr/kde/3.5/bin:/usr/qt/3/bin
I would stick with which. It is used by the fluxbox devs in their fluxbox-generate_menu script and it is a crossplatform script. They even have a workaround for systems in which the "which" command's return code is not reliable.
Bones McCracker wrote:On the other hand, regex is popular with the ladies.
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Fri Nov 09, 2007 7:49 am

the reason for that I used whereis, is that whereis is able to search also for libraries... I could switch to which but I'll still need something for the libraries...
Anyway, THANKS again for reply and support! I'll play with which again and see!
Top
yabbadabbadont
Advocate
Advocate
User avatar
Posts: 4791
Joined: Fri Mar 14, 2003 12:02 am
Location: 2 exits past crazy

  • Quote

Post by yabbadabbadont » Fri Nov 09, 2007 9:49 am

There isn't really a good reason to search for a library. You can't invoke a library. ;)

I would just verify that all the necessary executables are there. As long as you provide a clear list of all the script's dependencies in the documentation, that should be good enough.

I noticed that you are using perl in this version. (maybe you did in the last one too and I didn't notice) You shouldn't assume that perl will be installed on all systems. I think that it is part of the base gentoo system profile, but if you are trying for a crossplatform script (different Linux distributions, the BSD's, and maybe OSX), you shouldn't count on it. Just make sure to include perl in the list of dependencies. (that way when people complain that it doesn't work, you can point them to the documented dependencies ;))

By the way, "sed -e", produces the same output as your "perl -pi -e", with that substitution pattern. At least it does for me. (and sed is more likely than perl to already be installed)

Oh yeah, thanks for the honorable mention in the THANKS file. :D
Bones McCracker wrote:On the other hand, regex is popular with the ladies.
Top
max-232
Tux's lil' helper
Tux's lil' helper
User avatar
Posts: 105
Joined: Thu Mar 30, 2006 2:16 pm
Location: Italy

  • Quote

Post by max-232 » Sat Nov 10, 2007 10:03 am

ehi, I must to say that your suggestions are going to improve a lot the script!
- removed the checking for libdvdread (it's also a dependency of lsdvd) and switched to which
- removed the use perl
- added a check for "0" (zero) audio tracks selected

Thanks for continuing supporting!

Going closer to release the 1.1.2!
one question:
would it be useful to have a dvd without audio tracks? in place of just giving an error for "no audio tracks selected" I could let it build the dvd just without audio...but I don't know if this is feature could help someone...what is your opinion?

PS: I must (and I want) to put the name of whom helps me in the THANKS file...for those people, if you want your real name, sourname and e-mail address to be included, just send me an e-mail!
Top
Post Reply

40 posts
  • 1
  • 2
  • Next

Return to “Multimedia”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic