LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-28-2008, 01:31 AM   #1
slakka
LQ Newbie
 
Registered: Mar 2008
Posts: 12

Rep: Reputation: 1
AVI To DVD


So I wanted to write a one click script for converting an AVI file to DVD. The script uses mplayer and dvdauthor. Any input would be appreciated. Yes, I already know I am an amateur script writer, this is only my second attempt.

Code:
var_file_count=$(ls | grep ".avi" -c -i)
var_file_input=$(ls | grep ".avi" -i)
if [ $var_file_count == 0 ]; then
echo "No AVI files found in current directory. Please run script file from directory containg AVI files."
exit 0
elif [ $var_file_count -ge 2 ]; then
echo "More than one AVI file exists in this directory. Please place each AVI in it's own directory."
exit 0
else
var_file_width=$(exiftool -s -ImageWidth -s -s "$var_file_input")
var_file_height=$(exiftool -s -ImageHeight -s -s "$var_file_input")
var_aspect=`echo "scale=2 ; $var_file_width / $var_file_height" | bc`
var_aspect_test=`echo "sale=2 ; $var_aspect / 1.55" | bc`
if [ $var_aspect_test -gt 0 ]; then
var_aspect_input="16/9"
else
var_aspect_input="4/3"
fi
echo "File being proccessed:" $var_file_input
(mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf scale=720:480,harddup \
-srate 48000 -af lavcresample=48000 \
-lavcopts vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=9800:vbitrate=5000:keyint=18:aspect="$var_aspect_input":\
acodec=ac3:abitrate=192 -ofps 30000/1001 -o output.mpg "$var_file_input")
(dvdauthor -o dvd -x dvd.xml)
echo "Encoding and authoring completed. Please burn conetents of $PWD/dvd/VIDEO_TS to disc."
fi
exit 0
 
Old 10-28-2008, 03:26 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Well, I would recommend you add some spaces and comments to the script that way you know better what is going on. Have you tested it, does it work. If it does, then great. If not, say so and we'll help debug it.
 
Old 10-28-2008, 10:33 PM   #3
slakka
LQ Newbie
 
Registered: Mar 2008
Posts: 12

Original Poster
Rep: Reputation: 1
Forgot to mention it, but yes it works. The only part that I don't like is that dvdauthor requires a tie into an xml file for the chaptering of the dvd. This is the xml file structure I am using:

Code:
<dvdauthor>
	<vmgm />
	<titleset>
		<titles>
			<pgc>
				<vob file="output.mpg" chapters="0,10:00,20:00,30:00,40:00,50:00,60:00,70:00,80:00,90:00,100:00,110:00,120:00" />
			</pgc>
		</titles>
	</titleset>
</dvdauthor>
Is there anyway to pass this info to dvdauthor using straight command line?
 
Old 11-02-2008, 01:58 AM   #4
pintubigfoot
LQ Newbie
 
Registered: Nov 2008
Posts: 3

Rep: Reputation: 0
Instead of using script, why not use avidemux?
http://avidemux.sourceforge.net/
 
Old 11-02-2008, 03:22 AM   #5
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292Reputation: 1292
Well for one a script is more readily automated so you can do batches of DVDs.
 
Old 11-05-2008, 08:06 AM   #6
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,132
Blog Entries: 1

Rep: Reputation: 871Reputation: 871Reputation: 871Reputation: 871Reputation: 871Reputation: 871Reputation: 871
Is this just for personal use DVDs? Your dvdauthor setup is very limited, which probably wont play well with some stand alone players. Also, any reason why you're using mencoder? ffmpeg gives a better picture quality / maintains the quality of the source better. Mencoder IMO ends up looking a bit YouTube-ish no matter what options I give it.

Here's my little script for a dvd I recently authored. Which is called by another script passing the parameters for every video. flv, avi, mov, and various other input formats.

I'm my case I was standardizing audio as well. To include a second audio track in supposed 5.1 surround sound (not that I currently have any means to test it). And no delay for the rear channels, so probably pretty lame sounding if I could test it. Sources were either stereo or mono. And I left out a lot of the beta / commented lines. And not quite what I'm wanting yet. When authored it has the none audio, mpeg1 audio (stereo), and ac3 audio (surround) options in ogle. Previously before editing the audio and mplex-ing, it didn't have the none option, but it still defaults to the stereo setup on most players (ogle / xine / mplayer / kaffeine / vlc / ???). And I'm using MP2 for stereo audio to a) make it look different from the ac3 surround sound and to b) overcome mplex's dislike of WAV input. Perhaps it'll take wav input, but I wasn't able to find the parameters needed to make that happen.

$ sh below_script INPUT.AVI DVD_QUALITY.mpeg work_file_prefix

#!/bin/sh

if [ ! $1 ] || [ ! $2 ] || [ ! $3 ]; then
echo "ERROR ##########!!!!!!!!!!@@@@@@@@@@!!!!!!!!!!########## ERROR"
exit 1
fi

SRCFILE=$1
DVDFILE=$2
WORKPRE=$3

VIDFILE=$WORKPRE"_work_video_only.mpg"
M2VFILE=$WORKPRE"_work_video_only.m2v"
WAVFILE=$WORKPRE"_work_audio_only.wav"
CH2FILE=$WORKPRE"_work_audio_stereo.wav"
MP2FILE=$WORKPRE"_work_audio_stereo.mp2"
LEFTFILE=$WORKPRE"_work_audio_left.wav"
RIGHTFILE=$WORKPRE"_work_audio_right.wav"
CENTERFILE=$WORKPRE"_work_audio_center.wav"
LFEFILE=$WORKPRE"_work_audio_lfe.wav"
SURROUNDFILE=$WORKPRE"_work_audio_surround.ac3"

#EXTRACT VIDEO ONLY
ffmpeg -i $SRCFILE -an -sameq -aspect 4:3 -minrate 0 -maxrate 7000 -bufsize 1792 \
-target ntsc-dvd -y $VIDFILE

#CONVERT VIDEO to MPLEX friendly format
ffmpeg -i $VIDFILE -an -sameq -f mpeg2video -vcodec copy -y $M2VFILE

#EXTRACT AUDIO ONLY
ffmpeg -i $SRCFILE -vn -sameq -acodec pcm_s16le -ar 48000 -y $WAVFILE

#CONVERT AUDIO to STEREO and NORMALIZE
# (needed because some inputs were mono)
sox $WAVFILE -r 48000 -c 2 $CH2FILE
normalize-audio $CH2FILE

#CONVERT AUDIO to 5.1 SURROUND
sox $CH2FILE -r 48000 -c 1 $LEFTFILE avg -l
sox $CH2FILE -r 48000 -c 1 $RIGHTFILE avg -r
soxmix $LEFTFILE $RIGHTFILE -r 48000 -c 1 $CENTERFILE
sox -v 0.5 $CENTERFILE $LFEFILE lowp 150
aften -m 0 -b 448 -dsur 2 -acmod 7 \
-ch_fl $LEFTFILE -ch_fc $CENTERFILE -ch_fr $RIGHTFILE \
-ch_sl $LEFTFILE -ch_lfe $LFEFILE -ch_sr $RIGHTFILE \
$SURROUNDFILE

#CONVERT AUDIO to MPLEX friendly format
ffmpeg -i $CH2FILE -sameq -ac 2 -ar 48000 -ab 384k -y $MP2FILE

#MAKE the DVD track with TWO audio tracks
mplex -f 8 -o $DVDFILE $M2VFILE $MP2FILE $SURROUNDFILE
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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



Similar Threads
Thread Thread Starter Forum Replies Last Post
DVD to AVI justmovedtolinux Linux - Software 5 10-08-2008 11:48 PM
How do you create a DVD that can play in a DVD player from regular .avi videos? whited Linux - Software 2 04-09-2008 06:45 PM
avi to dvd berend27 Linux - Newbie 2 01-15-2008 06:44 PM
DVD AVI rip to DVD mooreted Mandriva 4 02-20-2005 09:57 AM
AVI on dvd? benne Linux - Software 3 02-05-2005 12:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:15 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