############################################# All of these scripts are designed to be run with an input file that lists the names of the images to be processed. All of mine were called IMG_????.JPG, so I just listed the number i.e. 0104 in the file. They are programmed to accept numbers, therefore. All scripts check for destination files so that nothing is overwritten. I did this so I could process subsets of my final project and not have to redo them in the end. ############################################# ######################################## This script automatically rotates and pads images with black (assuming they've been flipped to display correctly in the first place) and converts them to 704x480 resolution ######################################## rm -f untreated-files.txt for filenum in `cat zip.list` do file=IMG_${filenum}.JPG var=`jhead $file | grep Resolution` var=${var##*: } res1=${var% x *} res2=${var#* x } let "aspect = 1000 * $res1 / $res2" echo "$file: aspect ratio $aspect" if [ $aspect -eq 1333 ] then echo "$file is mode 1" if [ ! -e svcd/$file ] then convert -geometry '704x480!' -quality 100 $file svcd/$file else echo " svcd/$file: File exists" fi else if [ $aspect -eq 750 ] then echo "$file is mode 2" if [ ! -e svcd/$file ] then montage -geometry 4096x3072 -background black $file miff:- | convert -geometry '704x480!' -quality 100 miff:- svcd/$file else echo " svcd/$file: File exists" fi else echo "$file has unknown aspect ratio" echo $file >> untreated-files.txt fi fi done #################################################### This script does the same as the last one, except outputs ppm files. Using jpeg -quality 100 means that this script is unnecessary (i think) but if you want it, it's here. #################################################### mkdir -p svcd/ppm rm -f untreated-files.txt for filenum in `cat zip.list` do file=IMG_${filenum}.JPG var=`jhead $file | grep Resolution` var=${var##*: } res1=${var% x *} res2=${var#* x } let "aspect = 1000 * $res1 / $res2" echo "$file: aspect ratio $aspect" if [ $aspect -eq 1333 ] then echo "$file is mode 1" if [ ! -e svcd/ppm/${file%.JPG}.ppm ] then convert -geometry '704x480!' -depth 8 $file \ svcd/ppm/${file%.JPG}.ppm else echo " svcd/ppm/$file: File exists" fi else if [ $aspect -eq 750 ] then echo "$file is mode 2" if [ ! -e svcd/ppm/${file%.JPG}.ppm ] then montage -geometry 4096x3072 -background black $file miff:- | \ convert -geometry '704x480!' -depth 8 miff:- ppm:- | \ convert ppm:- svcd/ppm/${file%.JPG}.ppm else echo " svcd/$file: File exists" fi else echo "$file is unknown" echo $file >> untreated-files.txt fi fi done ############################################# This script converts mjpeg/pcm AVI files to mpeg2 480x480 aspect 4:3 files for inclusion on svcds. It used 2-pass encoded vbr. ############################################# for file in *.AVI do if [ ! -e ${file%.AVI}.mpg ] then ffmpeg -y -i $file -pass 1 -passlogfile pass1.log -b 2200k \ -maxrate 2600k -minrate 0 -bufsize 224k -s 480x480 -aspect 4:3 \ -r 29.97 -an -f mpeg2video /dev/null ffmpeg -y -i $file -pass 2 -passlogfile pass1.log -b 2200k \ -maxrate 2600k -minrate 0 -bufsize 224k -s 480x480 -aspect 4:3 \ -r 29.97 -an ${file%.AVI}.m2v ffmpeg -y -i $file -vn -ab 192k ${file%.AVI}.mp2 mplex -f 4 ${file%.AVI}.mp2 ${file%.AVI}.m2v -o ${file%.AVI}.mpg else echo echo "${file%.AVI}.mpg: File exists" echo echo fi done ##################################################### This script rotates video that may have been taken using a still camera turned sideways (for instance). It pads the sides with black and generates the same 480x480 4:3 output as the previous script. ##################################################### rm -f *.m2v *.mp2 *.log mencoder -nosound -ovc lavc -of mpeg -mpegopts format=xsvcd -vf \ rotate=1,expand=854:640,scale=480:480, -lavcopts \ vcodec=mpeg2video:mbd=2:keyint=18:vrc_buf_size=917:vrc_minrate=600:\ vbitrate=2000:vrc_maxrate=2500:aspect=4/3 -ofps 30000/1001 \ -o 1.m2v MVI_0212.AVI ffmpeg -i 1.m2v -vcodec copy 2.m2v ffmpeg -i MVI_0212.AVI -ab 192k 2.mp2 mplex -f 4 2.m2v 2.mp2 -o MVI_0212-1.mpg rm -f *.m2v *.mp2 ##################################### This script creates m2v files from 704x480 jpeg files. (SVCD stills) ##################################### if [ ! -e mpgs/m2v ] then mkdir -p mpgs/m2v fi for file in *.JPG do echo "$file ----> ${file%.JPG}.m2v" if [ ! -e mpgs/m2v/${file%.JPG}.m2v ] then jpeg2yuv -v 0 -f 29.97 -j $file -I p -n 1 | \ mpeg2enc -v 0 -a 2 -T 200 -n n -f 7 -o \ mpgs/m2v/${file%.JPG}.m2v else echo " mpgs/m2v/${file%.JPG}.m2v: File exists" fi done ################################################### This is the same script, except for ppms. Again you shouldn't need this, but it took a while to figure out. ################################################### if [ ! -e mpgs/m2v ] then mkdir -p mpgs/m2v fi for file in *.ppm do echo "$file ----> ${file%.ppm}.m2v" if [ ! -e mpgs/m2v/${file%.ppm}.m2v ] then ppmtoy4m -v 0 -S 420mpeg2 -F 30000:1001 -I p -n 1 $file | \ mpeg2enc -v 0 -a 2 -T 200 -n n -f 7 -o \ mpgs/m2v/${file%.ppm}.m2v else echo " mpgs/m2v/${file%.ppm}.m2v: File exists" fi done ############################################ This script is the same as the first script to generate m2vs from jpegs, but it uses a custom quantization matrix of the users choosing. It should be a comma delimited list with 128 values, 8 values per line ############################################ if [ ! -e mpgs/m2v ] then mkdir -p mpgs/m2v fi for file in *.JPG do echo "$file ----> ${file%.JPG}.m2v" if [ ! -e mpgs/m2v/${file%.JPG}.m2v ] then jpeg2yuv -v 0 -f 29.97 -j $file -I p -n 1 | \ mpeg2enc -v 0 -a 2 -T 200 -n n -f 7 -K file=custom-qm -o \ mpgs/m2v/${file%.JPG}.m2v else echo " mpgs/m2v/${file%.JPG}.m2v: File exists" fi done ############################################## This one is nice. It generates the xml file from a list of videos and numbers (for stills) that is parsed by vcdxbuild. It will set up the prev button to go to the previous slide and the next to the next slide. Return will return to the menu. The menu is put at the very end of the file and must be editted by hand. two files mainmenu.mpg and intro.mpg are included by default. The intro plays once upon insertion of the svcd and is never available again (until it's ejected). You can, of course remove the intro or menu. The files must exist if the descriptions are left in the xml ################################################ # three files are made and then concatenated. # 1 contains the top and segments # 2 contains the sequences # 3 contains the pbc # the input file "full.list" contains the order # for the disc. Movies should have full filenames # beginning with MVI_*.mpg let "count = 0" # set up beginning of top.xml (intro and segments) echo " Bill+Emma Euro08 1 1 0 Bill+Emma Europe 2008 CD-RTOS CD-BRIDGE Bill Burke " > top.xml # set up mid.xml (sequences) echo "" > mid.xml # set up bot.xml (pbc) echo "" > bot.xml for file in `cat full.list` do # add file to segments or sequences list # and set up variables if [ ${file:0:3} == "MVI" ] then # this is a video itemid="seq-${file%.mpg}" playid="play-${file%.mpg}" # add it to the sequences echo "" >> mid.xml else # this is a still file="IMG_$file.mpg" itemid="seg-${file%.mpg}" playid="play-${file%.mpg}" # add it to the segments echo "" >> top.xml fi # it is added to the file lists. now we add it to the pbc # if this is the first item, skip back should restart it if [ $count -eq 0 ] then prevplayid=$playid # note first playlist for menu generation later firstplayid=$playid else # if this is not the first pbc item, then we need to finish the # previous item's block echo " " >> bot.xml fi # now add the current file to the pbc in order echo " " >> bot.xml # set up "prev" variables for next time previtemid=$itemid prevplayid=$playid let "count = $count + 1" done # done with all files. finish out the sectional files echo " " >> top.xml echo " " >> mid.xml echo " \ 1 60 1 " >> bot.xml # concatenate them into one file cat top.xml > output.xml cat mid.xml >> output.xml cat bot.xml >> output.xml echo "Wrote output.xml" rm {top,mid,bot}.xml ############################################# This script muxes m2v's from the ./m2v directory with mp2's from the ./mp2 directory into mpgs in the current directory. This is for SVCD stills only. ############################################## for m2v in ./m2v/*.m2v do mp2=./mp2/${m2v#./m2v/} mp2=${mp2%.m2v}.mp2 dest=./${m2v#./m2v/} dest=${dest%.m2v}.mpg echo "$m2v + $mp2 ------> $dest" if [ -e $m2v -a -e $mp2 -a ! -e $dest ] then mplex -f 7 $m2v $mp2 -o $dest else if [ -e $dest ] then echo "Warning ---- $dest: File exists. Not performing mplex" fi if [ ! -e $m2v ] then echo "Error ---- $m2v: File doesn't exist" >> logfile.txt echo "Error ---- $m2v: File doesn't exist" fi if [ ! -e $mp2 ] then echo "Warning ---- $mp2: File doesn't exist. Encode without audio? (y/n)" read choice if [ $choice = "y" ] then mplex -f 7 $m2v -o $dest fi fi fi done ####################################### This script makes mp2's from all the wavs in a directory ######################################## for file in *.wav do echo "$file -----> ../${file%.wav}.mp2" if [ ! -e ../${file%.wav}.mp2 ] then ffmpeg -i $file -ab 64k ../${file%.wav}.mp2 else echo "../${file%.wav}.mp2: File exists" fi done