LinuxAnswers DiscussionThis forum is to discuss articles posted to LinuxAnswers.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Well ,I had a last minute sprint before my vacation.
New version 0.15b
Removed the alpha status. It is reliable enough to be beta now.
Changes:
-Color problems should all be fixed forever. I added some code that sets background colors for the text. (Thanks to SK545)
-The script now check for dependencies. If one is missing it will output a specific warning message and exit.
mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd are needed. Only K3B is optional.
-It now authors the movie with chapters every 15 minutes and creates a DVD compliant iso ready to burn. (I tested it myself just now)
-Thanks to the feedback from Narc I analyzed my code and changed it so it skips an unneeded step and consequently it takes a lot less time to complete the process from now on. This is good because the new DVD authoring with chapters takes a little time.
Also from the same fix, the space needed for the script operation are about 5 gigabytes lower than before.
So now the required space is down to 13 gigs even with the creation of an ISO image.
Thanks a bunch Narc!!!
My next objective are to let the user select more than one audio track. Also I will indroduce some error checking in the program to avoid to ungraceful crashes.
I also want to display the list of the available devices on the user system so that he can choose the proper DVD device as WapCaplet suggested earlier.
I also plan to make the script skip requantization if the calculated factor is 1.00 or lower.
All of this later, because I a leaving for a well deserved vacation. See you in 2 weeks...
I'll still check my e-mails , so feedback is welcomed.
Here is the code:
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-01-16
# Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd / K3B
#===========================================================================
# Presentation
clear
version=0.15b
COLOROFF="\033[1;0m" # standart color
COLOR1="\033[40;32m" # green
COLOR2="\033[40;37m" # white
COLOR3="\033[40;36m" # blue
COLOR4="\033[40;31m" # red
echo -e "${COLOR1} ===================="
echo -e "${COLOR4} * DVRequant v${version} *${COLOR1}"
echo -e "${COLOR1} ===================="
echo -e "$COLOR3"
echo "Requirement: mplayer / libdvdcss / transcode / mjpegtools / dvdauhtor / cdrecord (mkisofs) / lsdvd / K3B"
echo " "
echo "K3B is optional but recommended"
#============================================================================
# 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 /usr/lib/libdvdcss.so.2 >/dev/null ; then
echo " "
echo "libdvdcss 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
#===========================================================================
# Create project folder and choose preferences
echo
echo "We will create a work folder called dv_output in the path of your choice. Make sure you have at least 11 gigabytes of space available."
echo " "
echo -n "Enter the path to create the directory (ex. /home/bobby/video) >"
read -e loc
cd $loc
mkdir dv_output
#==========================================================================
# Define path to DVD device
echo " "
echo -n "Enter name of your DVD device (ex. /dev/dvd or /dev/hdc) >"
read -e dvd
echo -e "$COLOR4"
#==========================================================================
# Ask the user witch video title he wants to rip from DVD
#video stream sub-section
echo " "
echo "============================================= "
echo "These are all the video titles on the disc"
echo "============================================= "
echo " "
echo -e "$COLOR3"
lsdvd -v $dvd | more
# tcprobe method
# tcprobe -i $dvd -T 1 -H 10 #not implemented 2>&1 | egrep " \[chapters ..\] " > chapters
echo -e "$COLOR4"
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
echo -e "$COLOR1"
#audio stream sub-section
echo " "
echo "========================================== "
echo "These are all the audio tracks on the disc"
echo "========================================== "
echo " "
lsdvd -t $title -a | cut -c 1-100
echo -e "$COLOR4"
echo " "
echo -n "Enter the language code you wish to rip (ex. en or fr) >"
read -e track
echo -e "$COLOR3"
echo "================================================= "
echo "The DVD will now be ripped, it may take some time."
echo "================================================= "
echo " "
echo -e "$COLOR2"
#==========================================================================
# Rip the DVD
# Rip selected video title
mplayer -dvd-device $dvd dvd://$title -dumpvideo -dumpfile $loc/dv_output/output.m2v
# Rip selected audio tracks
mplayer -dvd-device $dvd dvd://$title -dumpaudio -alang $track -dumpfile $loc/dv_output/lang.ac3
#this can be modified to rip any other languages by replacing "fr" by any other appropriate codes:
echo -e "$COLOR3"
echo " "
echo "====================================== "
echo "You can eject the DVD now if you want."
echo "====================================== "
echo " "
#==================================================================================
# De multiplex the video stream and the audio stream (-d2 is for verbosity)
#echo -e "$COLOR3"
#echo "Demultiplexing streams...."
#echo " "
#cd $loc/dv_output
# tcextract -i output.mpg -t vob -x mpeg2 -d2 > output.m2v
# tcextract -i output.mpg -a 0 -x ac3 -t mpeg2 -d2 > trash.ac3
# Cleaning up a bit...
#rm trash.ac3
#rm output.mpg
#===================================================================================
# 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 -e "$COLOR4"
echo " "
echo "================================== "
echo "Calculating best requant factor..."
echo "================================== "
echo "==========================================="
echo "The closer to 1.00 the factor is the better."
echo "=========================================== "
echo " "
cd $loc/dv_output
vsize=`du -b output.m2v | cut -c 1-10` # video_size
audio=`du -b lang.ac3 | cut -c 1-9` # audio_size
dvdlessaudio=$((4700000000-$audio))
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 " "
#===============================================================================
# Requantize it:
echo -e "$COLOR1"
echo "========================================= "
echo "Requantizing (shrinking) the video stream."
echo "========================================= "
tcrequant -d2 -i output.m2v -o shrinked.m2v -f $req
# Cleaning....
rm output.m2v
#========================================================================
# Remultiplex:
echo -e "$COLOR3"
echo " "
echo "====================================== "
echo "Multiplexing audio and video stream(s)."
echo "====================================== "
echo " "
mplex -f 8 -o final.mpg shrinked.m2v lang.ac3
# Cleaning up
rm lang.ac3
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 -e "$COLOR4"
echo " "
echo "========================================= "
echo "Authoring and generating a DVD structure."
echo "========================================= "
#mkdir $loc/dv_output/dv_dvd
# Populate filesystem
dvdauthor -t -o dv_dvd -c 0,15:00,30:00,45:00,60:00,75:00,90:00,105:00,120:00,135:00,150:00,165:00,180:00,195:00 final.mpg
# Create IFO files
dvdauthor -o dv_dvd -T
# Create DVD Video compliant ISO image
mkisofs -dvd-video -udf -o ready2burn.iso dv_dvd/
#========================================================================
# End messages
echo -e "$COLOR3"
echo " "
echo "==============================================================================="
echo "Done! Use K3B to burn the - ready2burn.iso- "
echo " created in the dv_output folder."
echo "==============================================================================="
echo -e "$COLOROFF"
exit
Its like one has to focus a bit hard to see what the name of the script is in red under a black blackground, for example. Still, its a improvement over the previous one.
Is there a reason why you won't put this in its own project under freshmeat or sourceforge? I think it would be easier for you instead of posting the script over and over in here. It should be easier for us as well since we won't make copying/pasting mistakes. /edit: nevermind, i forgot this was going to be part of tovid, so thats probably why..
Well after the Tovid thing, I will probably submit it on sourceforge as a stanalone apps too. But as you said I will focus to help Wapcaplet first.
I wiil rework the colors again and resubmit too you next time.
As for the problem with libdvdcss, for now all you need to do to make it work until I fix it is to erase the portion between line 44 and 50 from your script and it will move on to the rest of the process.
This is the portion you need to erase from the script:
Code:
if ! which /usr/lib/libdvdcss.so.2 >/dev/null ; then
echo " "
echo "libdvdcss is not detected";
echo "you need it installed. Exiting...";
echo " "
false; exit;
fi
Since you do have libdvdcss, it won't be a problem and I will fix it later. It's only a question of path and it is my mistake.
You can do this to fix any dependencies that give you problems until I get around to work on fixing the bug.
Steel_J,
Can't tell you how I like seeing your script change over time. Keeps getting
better and better.
1 tech question if you don't mind:
(P.S. I know your on vacation - no immedite response needed - have fun!
On the output, on the " lsdvd -v $dvd | more " command, I get this using one dvd
- but not on others. Whats the scoop?
Code:
=============================================
These are all the video titles on the disc
=============================================
libdvdread: Using libdvdcss version 1.2.8 for DVD access
libdvdread: Can't seek to block 2955891
libdvdread: Can't seek to block 2955891
libdvdread: Invalid IFO for title 2 (VTS_02_0.IFO).
Can't open ifo 2!
What title do you want to rip? (ex. 1, 2 or 3) >1
The script continues, and works, but I don't recall seeing that before. I usually get
something like this (not the full output)
Code:
libdvdread: Using libdvdcss version 1.2.8 for DVD access
[tcprobe] DVD image/device
libdvdread: Using libdvdcss version 1.2.8 for DVD access
(dvd_reader.c) mpeg2 ntsc 4:3 U0 NTSC CC 1 720x480 video
(dvd_reader.c) ac3 en drc 48kHz 1Ch
(dvd_reader.c) subtitle 00=<en>
(dvd_reader.c) subtitle 01=<fr>
(dvd_reader.c) subtitle 02=<es>
(dvd_reader.c) DVD title 1/2: 33 chapter(s), 1 angle(s), title set 1
(dvd_reader.c) title playback time: 01:38:11.18 5892 sec
(dvd_reader.c) [Chapter 01] 00:00:00.000 , block from 4208 to 50138
(dvd_reader.c) [Chapter 02] 00:02:13.767 , block from 50139 to 119715
AND SO ON
I did compare the 2 scripts (different versions, 14a & 15b), and they look like they are doing the
same thing. Just wondering for my own knowledge.
Keep up the great work!
And thanks a lot for the chapters every 15 min.!!!!!!!!!
sk545 ( & Steel_J )
Topic: colors.
Personally I like the color scheme. BUT, if my console had a white background like
sk545's, I think I would be in the same boat. But mine is black, so it looks good,
This is one of the reasons why I like this project so much. NOT being a programmer,
using a shell script makes it easy to alter it a bit to suit my needs. Example: I add a section
at the end to delete the /dv_output/dv_dvd directory - becuase I don't want it after the iso
is made. BUT, If Steel_J ever adds a line to delete the final.mpg after the creation of the iso,
I would remark it out - because I generally want to keep it atleast for a little while.
Following that thought, sk545, don't be affraid to make the colors suit your personal
needs/tastes. The script will still work just fine. If you want to, here is some info to get
you started.
Quote:
foreground (text)
30 (black), 31 (red), 32 (green), 33 (yellow), 34 (blue), 35 ( magenta), 36 (cyan), 37 (white).
background
40 (black), 41 (red), 42 (green), 43 (yellow), 44 (blue), 45 ( magenta), 46 (cyan), 47 (white).
The same as forground except with a '4' instead of a '3'.
# PART OF THE SCRIPT THAT DEFINES THE COLORS
COLOROFF="\033[1;0m" # standart color
COLOR1="\033[40;32m" # green
COLOR2="\033[40;37m" # white
COLOR3="\033[40;36m" # blue
COLOR4="\033[40;31m" # red
if you are having trouble with green, but like the cyan (for example) change:
COLOR1="\033[40;32m" # green
to
COLOR1="\033[40;36m" # cyan
I don't want to get in the middle of development, nor telling Steel_J not to change the
script, just giving options for the end users. If Steel_J does end up changing it, if it is
not as good for me, I might change them back to where they are now.
Thats the beauty of open source.
best regards to all,
-tw
Has anyone tried xine-transcode (http://www.rengels.de/xine-transcode/index.html)?
It seems to me, after briefing the README, that it is able to do a dvd5 backup of a dvd9-disc with all menus and subtitles preserved. Can someone confirm this? It requires a rebuild of the xine-lib and I have no time for that right now :-)
Originally posted by }-{ello Steel_J's script[s] works fine, but we need also to get subtitle into the DVD, perhaps even the selectable subtitle.
Dunno if http://www.bunkus.org/dvdripping4lin...text_compiling is any help.
I've done this with spunmux. The procedure is something like this:
vobcopy - entire disk to hd
spuunmux - the subtitle of your choosing from the VOBs
tcextract - separate movie from sound
tcrequant - shrink it
mplex - shrunken movie + sound
spumux - add subtitles to movie
dvdauthor - ...
mkisofs - ...
Problem with this method is that (I think) you make the the subs a permanent part of the movie, so no selectable subtitles.
Also it is not a duplicate since vobcopy suffers from the same problem as streamdvd: You have to choose a "title" and I doubt that you get the main menus etc. I guess this is ok if it's a film you're copying. It is however not satisfying if you want to backup, for example, a tv-series DVD.
Tuxqs script will do the same thing if you specify a subtitle stream but a whole lot faster since nothing has to be mux/plex'ed or backed up to disk. I guess... I've just looked at the code, haven't tried it yet.
The only method I've discovered so far that will actually dump the entire disk to hd, preserving the structure, is
dvdunauther. I still have not figured out how to shrink all the titles of the DVD yet. Perhaps someone can give me some input on this?
**ERROR: [mplex] Need to split output but there appears to be no %d in the filename pattern /mydvd/join.vob
... where /mydvd/join.vob is of course my joint shrinked video and audio track. The video is just around 3G while the audio is around 300M. I can't undestand why it would ask to split. I never got such a response before. I don't see any options in my command line that would force. Right now, my output vob is just a little over 3G. I'm not sure it copied it all. :-(
narc.
---
Update: Seems everything was copied but I'll appreciate any other feedback on the preceeding error. I read the man page and other forums: most of the people who report this kind of error try to write (S)VCDs with option -S for splitting. The default value for -S is 0 (unlimited).
I finally got the time to try out the new dvrequant, here is what i thought:
- Hey, it works! And it works good.
- There isn't any mention of what the default behaviour is if someone hits Enter instead of putting in something like /dev/hdc.
- When its looking for the chapters on the dvd, there is a long list of them and at the bottom, it says 'More'. So, you have to hit the space bar to keep going. Initially i was hitting Enter, which messed things up.
- It doesn't give much of a report on the status of what it is doing, i.e., it hangs like so:
DVD successfully opened.
Cache fill: 6.25% (65536 bytes) MPEG-PS file format detected.
- I was unable to play the resulting iso file with the command 'xine dvd://path/to/iso.' But when the iso is burnt to a dvd, the dvd plays fine.
- The colors will be fixed later so i am not going to keep repeating here.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.