Quote:
Originally Posted by mucktuck
how on earth would you do multiple files at once? I attempted and it only did the first file I entered in. I am supposed to put comma's inbetween each name? or does this not support multiple files? or am I just inept at shell script(very likely).
|
After finding this page, I built my own script to handle multiple files.
Code:
#! /bin/sh
### CHECK FOR ARUGUMENTS ###
if [ -z $1 ];
then
usage=`echo 'Usage: avi2dvd [file1.avi, file2.avi, ...,]'`
echo $usage
exit
fi
### BEGIN CREATING THE DVD AUTHOR XML ###
echo '<dvdauthor dest="DVD">' > dvdauthor.xml
echo ' <vmgm />' >> dvdauthor.xml
echo ' <titleset>' >> dvdauthor.xml
echo ' <titles>' >> dvdauthor.xml
### STORE LIST OF ARUGUMENTS INTO TMP FILE ###
echo $* | awk -F ' ' '{i=1
while (i <= NF) {print $i;
i++} }' > tmp
### VERIFY THE ARUGMENTS ARE VALID ... ###
while read line
do
isFile=`ls $line 2>&1`
error='ls: cannot access '$line': No such file or directory'
case $isFile in
$error) ### IF ls RETURNS THE ERROR STRING ...
echo $line 'is not a valid file'
exit
;;
*) ### ELSE, WE ARE OK FOR NOW
;;
esac
### NOW CHECKING FILE TYPE (THIS VERSION ONLY SUPPORTS AVI)
fileType=`echo $line | awk -F '.' '{i=1
while (i <= NF) {if (NF == i) print $i;
i++} }'`
echo $fileType
case $fileType in
avi) ### IF ITS AVI, WE ARE READY
echo $line 'is ready for transcoding'
;;
*) ### IF NOT, LIGHTS OUT, TRY AGAIN
echo $line 'is not a valid avi file'
exit
;;
esac
done < tmp
### COMPUTING TOTAL DURATION ###
totalDur=0
while read line
do
thisDur=`ffmpeg -i $line 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,// | awk -F '.' '{print $1}' | awk -F ':' '{print $2}'`
totalDur=$(($totalDur+$thisDur))
done < tmp
if [ $totalDur -gt 120 ]
then
echo 'WARNING: This project is '$totalDur' minutes, which will not fit on a standard DVD'
echo 'PRESS ENTER TO CONTINUE or "Q" TO QUIT'
read choice
if [ "$choice" = "Q" ]; then
exit
fi
echo 'BEGINNING TRANSCODING ...'
fi
echo 'PROCESS CAN TAKE BETWEEN' `echo "scale=3; ($totalDur/75)*60" | bc` 'AND '$totalDur' MINUTES, DEPENDING ON AVAILABLE RESOURCES'
echo 'IT IS ADVISED YOU CLOSE ALL OTHER PROCESSES TO ENSURE MAXIMUM EFFICIENCY'
echo '<ENTER>'
read enterKey
### READY TO BEGIN TRANSCODING, MPLEX, AND AUTHORING OF THE DVD ###
while read line
do
### THIS AWK SCRIPT GRABS JUST THE FILE NAME WITHOUT EXTENSION
movie=`echo $line | awk -F '/' 'END {i=1
while (i <= NF) {if (NF == i) print $i;
i++} }' | awk -F '.' 'END {i=1
while (i <= NF) {if (NF != i) printf $i;
i++} }'`
### GETTING THE LENGTH OF THE FILE IN HH:MM:SS TO SETUP CHAPTER POINTS
len=`ffmpeg -i $line 2>&1 | grep Duration | cut -d ' ' -f 4 | sed s/,// | awk -F '.' '{print $1}'`
### INSERTING THE VIDEO FILE IN THE XML
echo ' <pgc>' >> dvdauthor.xml
echo ' <vob file="dvd_'${movie}'.mpg" chapters="0,'$len'"/>' >> dvdauthor.xml
echo ' </pgc>' >> dvdauthor.xml
### TRANSCODING (SPLITTING THE VIDEO INTO AUDIO AND VIDEO FILES
transcode -i $line -y ffmpeg --export_prof dvd-ntsc --export_asr 3 -o ${movie} -D0 -s2 -m ${movie}.ac3 -J modfps=clonetype=3 --export_fps 29.97
### MPLEX (JOINING THE TWO FILES BACK INTO A MPG FILE
mplex -f 8 -o dvd_${movie}.mpg ${movie}.m2v ${movie}.ac3
done < tmp
### FINISH THE XML ###
echo ' </titles>' >> dvdauthor.xml
echo ' </titleset>' >> dvdauthor.xml
echo ' </dvdauthor>' >> dvdauthor.xml
### AUTHORING THE XML WITH DVDAUTHOR ###
dvdauthor -x dvdauthor.xml
### PROMPT USER FOR DVD BURNING OPTION ###
echo 'Would you like to burn your DVD now? (Y or N)'
read burn
if [ "$burn" = "Y" ]
then
growisofs -Z /dev/dvd -dvd-video DVD/
fi
I commented as much as I can for the benefit of others, but here is how it works in a nutshell:
1) choose your input files (it supports as many as you put in)
2) it will then gather all the information needed about the file(s) and alert you if a) your file cannot be found or accessed b) if the file is not an avi file (you can trick my script and name the file .avi but the transcoders will pick it up).
3) it will prompt if the total amount of files are too large for a standard DVD and ask if you want to continue. Also, the total amount of time, percentage, and time remaining on a standard DVD will be displayed.
4) It will take up to two hours (realistically, not that long) depending on your computer, number and size of files, and available resources. I noticed that sometimes it would run in the high 60s frames per second transcoding (which is the longest process) up to 85 FPS, so it really varies.
5) After all processes are done, it will ask if you want to burn to a DVD. If you say 'Y' it will burn it for you, else it will exit and leave you with the DVD files in your home folder under DVD/