LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-23-2005, 08:44 AM   #1
bglnelissen
Member
 
Registered: Feb 2004
Location: Utrecht Holland
Distribution: MacOS, Debian, Raspbian
Posts: 76

Rep: Reputation: 15
AVI to DVD script


WORKS, but is not finished.
Here is a little avi to dvd BASH-script.
its for PAL but the right lines for NTSC are there. (look at step 1)
Change things if you want to.
have fun.
bas
Code:
#!/bin/bash
# made by CousinCocaine (bglnelissen)
# All this info comes from one of my favorite websites:
# http://www.linuxquestions.org
# more specific:
# http://www.linuxquestions.org/questions/answers/556
# thnx ptesone ;)

# STEP 0
# Say hello
# give worning for the dependencies
# setting-up the right directories, variables etc

# FUNCTION FOR MAKING COLORTEXT EASIER
function echolightgray {
	echo -e "\033[37;0m $1 \033[0m"
	}
function echodarkgray {
	echo -e "\033[30;1m $1 \033[0m"
	}
function echolightblue {
	echo -e "\033[34;1m $1 \033[0m"
	}
function echolightgreen {
	echo -e "\033[32;1m $1 \033[0m"
	}
function echolightcyan {
	echo -e "\033[36;1m $1 \033[0m"
	}
function echolightred {
	echo -e "\033[31;1m $1 \033[0m"
	}
function echolightpurple {
	echo -e "\033[35;1m $1 \033[0m"
	}
function echoyellow {
	echo -e "\033[33;1m $1 \033[0m"
	}
function echowhite {
	echo -e "\033[37;1m $1 \033[0m"
	}
#emptying terminal
reset

echo -e "Hello world!"

echoyellow "Welcome to \"avi-2-DVD\""
echolightcyan "\t Your 6 Steps guide for converting avi-2-DVD"
echolightgreen "Read Me:"
echo -e "Just do everything this program asks you to do and it will work like a charm.
Make sure you have installed these programs before trying to converd avi-2-DVD:
	\t - transcode
	\t - mplex
	\t - dvdauthor
	\t - k3b"
echo ""
echo -e "This program can be quit anytime using \"ctrl-c\".
No wildcards and there (still) are no error correction for misspelled path's or filenames.
Make shure you've got enough free disc-space.
Files are not yet cleaned afterwards.
Settings now used are for PAL format, NTSC settings can be found in the source of this script.
Enough said, lets start your avi-2-DVD project!"
echo ""
echoyellow "What's the name of your new avi-2-DVD project?"
read project
echo ""

echoyellow "In which FOLDER is the \".avi\" file you want to convert?"
echo -e "Type it's path here: 
	\r\t (like: /home/myname/movies)"
read workingdir
cd  "$workingdir"
echo ""

echoyellow "Which of the following movie(s),listed below, do you want me to convert?"
echo -e "Remember, no wildcards and there (still) are no error correction for misspelled path's or filenames."
echo ""
echolightgreen "List all \".avi\" movies in this folder:"
ls | grep .avi
echo ""
read avimovie
echo ""

echo -e "To make shure the process does not conflict with other files ill make a new working directory:"
echolightgreen "\"$workingdir/DVD $project\""
mkdir "DVD $project"
mv "$avimovie" "DVD $project"
cd "DVD $project"
	
# STEP 1
# Split the .avi file into 2 separate files, one for video and one for audio
# (This AINT 5.1, see website for details)
echo ""
echolightcyan "\t Step 1"
echoyellow "Split the .avi file into 2 separate files, one for video and one for audio:
\t - 1 video file, '.m2v'
\t - 1 audio file, '.ac3'"
sleep 2
transcode -i "$avimovie" -y ffmpeg --export_prof dvd-pal --export_asr 2 -o "$avimovie" -D0 -b224 -N 0x2000 -s2 -m "$avimovie".ac3 -J modfps=clonetype=3 --export_fps 25 
#PAL
#transcode -i "$avimovie" -y ffmpeg --export_prof dvd-pal --export_asr 2 -o "$avimovie" -D0 -b224 -N 0x2000 -s2 -m "$avimovie".ac3 -J modfps=clonetype=3 --export_fps 25 
#NTSC
#transcode -i "$avimovie" -y ffmpeg --export_prof dvd-ntsc --export_asr 2 -o "$avimovie" -D0 -b224 -N 0x2000 -s2 -m "$avimovie".ac3 -J modfps=clonetype=3 --export_fps 29.97

# Moving back videofile
echolightgreen "Restoring original videofile: $avimovie"
mv $avimovie ../

# STEP 2
# Put the video & audio file back together
# This will make dvd_movie.mpg ready for DVD authoring. . .
echo ""
echolightcyan "\t Step 2"
echoyellow "Put the video & audio file back together (MPEG)"
sleep 2
mplex -f 8 -o dvd_movie.mpg "$avimovie".m2v "$avimovie".ac3

# STEP 3
# open your favorite text editor and paste the following
# save the file as: dvdauthor.xml
# in the same directory as your movie files '
echo ""
echolightcyan "\t Step 3"
echoyellow "Now i am gonna create a \"dvdauthor.xml\" file.
The 'dvdauthor' program uses this file to create the right DVD structure"
sleep 2
echo -e "<dvdauthor dest=\"DVD\">  
	  <vmgm /> 
	   <titleset> 
	     <titles> 
	       <pgc> 
	         <vob file=\"dvd_movie.mpg\" chapters=\"0,15:00,30:00,45:00,1:00:00\"/> 
	       </pgc> 
	      </titles> 
	   </titleset> 
	 </dvdauthor>" > "dvdauthor.xml"

# STEP 4
# using the dvdauthor.xml file to create a DVD from the dvd_movie.mpg file
echo ""
echolightcyan "\t Step 4"
echoyellow "Starting up dvdauthor and using your \"dvdauthor.xml\" file..."
sleep 2
dvdauthor -x dvdauthor.xml

# STEP 5
# starting-up k3b for burning the whole project
echo ""
echolightcyan "\t Step 5"
echoyellow "Starting k3b with additional options for buring your dvd"
echoyellow "Click 'Burn' and again, click 'Burn' to start burning your disc"
cd "$workingdir/DVD $project/DVD"
ls
sleep 4
k3b --videodvd ./*

# STEP 6
# ALL DONE
echo ""
echolightcyan "\t Step 6"
echoyellow "Everything is done. Enjoy your DVD"
echoyellow "Your DVD image files and you project files still excist in: \"$workingdir/DVD $project\""
echo -e "Thnx ptesone & CousinCocaine for making this possible"
echo -e "Bye"

Last edited by bglnelissen; 05-12-2007 at 10:42 AM.
 
Old 10-23-2005, 09:18 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
Do you know where my red stapler is?
 
Old 10-23-2005, 12:06 PM   #3
bglnelissen
Member
 
Registered: Feb 2004
Location: Utrecht Holland
Distribution: MacOS, Debian, Raspbian
Posts: 76

Original Poster
Rep: Reputation: 15
red stapler

else you gonna burn down the building?

Last edited by bglnelissen; 10-23-2005 at 01:55 PM.
 
Old 10-25-2005, 01:51 PM   #4
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
do you have any ideas for twother way 'round?

i'm having problems 'transcod'ing a dvd i own...

thank you,
________________

and dont forget your cover to the tps reports.

Last edited by schneidz; 10-25-2005 at 01:56 PM.
 
Old 10-27-2005, 07:46 AM   #5
bglnelissen
Member
 
Registered: Feb 2004
Location: Utrecht Holland
Distribution: MacOS, Debian, Raspbian
Posts: 76

Original Poster
Rep: Reputation: 15
mencoder is your buddy on this one

This what i use, its Dutch, sorry, but no time to translate. Always run the program with the 4 options:
- length in minuits
- titel
- volume gain (else very low sound output)
- Number of cd's you want (1 or 2 or 3 etc This will give output like 700 - 1400 - 2100 mb etc)

a dvd contains more than one titel, sometimes you dont know which titel contains you movie. Check this by running:
$ mplayer dvd://1
or mplayer dvd://3 etc etc etc
if you found the right titel, change it in the code, default is now 1. (search for dvd://1)

also check the output location

cant help you further.
LUCK

greetings Bas

AND REMEMBER, COMMANDLINE OPTIONS CANT CONTAIN SPACES SO USE ¨for titel¨

Code:
#!/bin/bash
# Script made by B.Nelissen 
# I want thist script to rip a DVD to divx.avi and also give the oppertunity to burn the divx files to cdrom, with Movix if possible.

# 1 - Analysing DVD and give prognosis for process (time, free discspace needed etc)
# 2 - Ripping DVD and convert to divx in 1 pass
# 3 - Split avi file when necessary , when > 700 mb
# 4 - Burning each avi file to cdrom, with or without Movix
# 5 - Give summary of result

# FUNCTION FOR MAKING COLORTEXT EASIER
# Little function for writing text in red
function echored {
	echo -e "\033[31;1m $1 \033[0m"
	}
# Little function for writing text in green
function echogreen {
	echo -e "\033[32;1m $1 \033[0m"
	}
# Little function for writing text in yellow
function echoyellow {
	echo -e "\033[33;1m $1 \033[0m"
	}
# Little function for writing text in blue
function echoblue {
	echo -e "\033[34;1m $1 \033[0m"
	}

# Little function for writing a emptyrule
function  emptyrule {
	echo ""
	}

if [ $# != 4 ] ; then
    echoyellow "Use: $0 <lengte van de film in minuten> <\"titel van de film\"> <volume versterking (1-10)> <Number of CD's (1-3)>..."
    echo "(De titel moet tussen 'haakjes')" 
    echo "(De qualiteit blijft er goed als er per uur film één CD gebruikt wordt)"
    emptyrule
    exit 1
fi
          
echo "Use program like this:"
echo "dvdrip.sh 210 movie.avi 4 1"
echo ""
echo "210 = minuits of movie"
echo "movie.avi = titel of movie"
echo "4 = Sound gain (you need this!)"
echo "1 = Number of cd's to put movie on"

# Check if the given number for volume adjustment is between 0 and 5
# These numbers are also use by the AVISPLITTER

# Check if the given number of CD's is 1 or 2 or 3.
# -le = less or equal


# Biggest file size is 700mb per CD, which is 716800kbytes 
# but   just   in  case   we  use a little smaller size
# There is a possibility to burn the movie on 1, 2 or 3 CD's

MAXSIZE=$(($4*710000))

# LANGUAGE SETTINGS alang = audio slang = subtitels
ALANG=en
SLANG=ne

# INPUT VIDEO (WIL NOG MAKEN DAT DEFAULT 1 WORDT)
INPUTVIDEO=dvd://1

# OUTPUTLOCATION MOET MET "/" EINDIGEN
OUTPUTLOCATION=~/films/

# TIMER BEFORE STARTING ENCODING, IN SECONDS
TIMER=15

# SEGUNDOS=$1
# MINUTES=$(($SEGUNDOS/60))
MINUTES=$1
SECONDS=$(($MINUTES*60))
FILENAME=$2.avi
VOLUME=$3

#Audio rate is 128bits/s which is 16kbytes/s
AUDIOSIZE=$((16*$SECONDS))
LIBRE=$(($MAXSIZE - $AUDIOSIZE))
RATE=$((($LIBRE*8) / $SECONDS))

# Calculate estimated file size
FINALSIZEKB=$(( ($RATE * $SECONDS)/8 + $AUDIOSIZE))
FINALSIZEMB=$(( $FINALSIZEKB/1024))
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo ""
echo "###############################################################"
echo ""
echo -e "Analyseren van de film:      \033[33;1m $2 \033[0m..."
echo ""
echo ""
echo "U heeft gekozen voor:"
echo ""
echo -e "Titel:                       \033[33;1m $2 \033[0m"
echo -e "Lengte:                      \033[33;1m $1 minuiten \033[0m"
echo -e "Volume versterking:          \033[33;1m $3 \033[0m"
echo -e "Number of Disc's:            \003[33;1m $4 Disc/Disc's \033[0m"
echo ""
echo -e "Geschatte rate:              \033[33;1m $RATE \033[0m"
echo -e "Geschatte bestandsgrootte:   \033[33;1m $FINALSIZEMB MB (= $FINALSIZEKB KB) \033[0m"
echo -e "De film wordt opgeslagen als:\033[33;1m '$OUTPUTLOCATION"$FILENAME"' \033[0m"
echo ""
echo "Het commando dat nu wordt opgegeven aan mencoder is:"
echoyellow "mencoder $INPUTVIDEO -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=$RATE -vop scale -zoom -xy 640 -alang $ALANG -oac mp3lame -lameopts abr:br=128:vol=$VOLUME -o '$OUTPUTLOCATION"$FILENAME"'"
echo ""
echo ""
echo ""
echo "###############################################################"
echo "                                                     B.Nelissen"
echo ""
echo ""
echoyellow "The process starts in $TIMER seconds, to cancel press ctrl-c"

# Ask for final call
echo -e "\033[33;1m Starting the process, sit back and enjoy (it can take a while.... it can take hours.... )\033[0m"

# mencoder $command
 mencoder $INPUTVIDEO -ovc lavc -lavcopts vcodec=mpeg4:vhq:vbitrate=$RATE -vop scale -zoom -xy 640 -alang $ALANG -oac mp3lame -lameopts abr:br=128:vol=$VOLUME -o $OUTPUTLOCATION"$FILENAME"




# The following code will decide weather the avi file will be splitted or not.

Last edited by bglnelissen; 10-27-2005 at 07:50 AM.
 
Old 10-27-2005, 02:00 PM   #6
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
hmm, i'll have to try it.

looks good, thanks
 
  


Reply



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
AVI to DVD ptesone Linux - Software 9 07-21-2009 08:11 PM
Dvd to Divx (avi) Knowledgements Debian 8 08-21-2005 01:57 PM
AVI to DVD format Mongrel-3 Linux - Software 1 08-21-2005 12:30 AM
DVD AVI rip to DVD mooreted Mandriva 4 02-20-2005 08:57 AM
AVI on dvd? benne Linux - Software 3 02-05-2005 11:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:33 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
Open Source Consulting | Domain Registration