#!/bin/sh # Written by David Ranch # 06/26/01 - v1.00 # # http://rocko.csuchico.edu/~dranch/tivo/index.html # Assumptions: # # 1) the media files are in the current directory # # 2) all tools like mpeg2dec, mpeg2enc, toolame, vdimager, and cdrdao are also # in the current directory # # 3) You have bash, awk, bc, sox's play, and mpg123 in your PATH # # 4) You have the various KDE sound files installed # # 5) You need to change the device number for your CDR drive and the correct # speed. I recommend that you use CD-R/W disks until you confirm that # you have a perfect mpeg1 file # # Notes: Please note that ANY "Sequence number bogus" or "audio failure" errors from # ExtractStream can cause a fatal timing issue between the video and audio # playback. You've been warned. # if [ "$1" == "" ]; then echo -e "\n Usage: convert-it " exit 0 fi echo -e "\nConverting $1 media..\n" #If the m1a file not present or if the existing m1a file is less than 20M.. abort TEMP=`ls -la $1.m1a 2> /dev/null | awk '{print $5}'` if [ ! -f $1.m1a ] || [ $TEMP -lt 20000000 ]; then #Convert audio in background mpg123 -s -r 44100 --wav - $1.m2a | ./toolame -p 2 -b 224 - $1.m1a & else echo -e "$1.m1a file exists.. skipping..\n" fi #If the m1v file not present or if the existing m1v file is less than 200M.. abort TEMP=`ls -la $1.m1v 2> /dev/null | awk '{print $5}'` if [ ! -f $1.m1v ] || [ "$TEMP" == "" ] || [ $TEMP -lt 200000000 ]; then #Convert audio in forground as it takes the longest cat $1.m2v | ./mpeg2dec -o YUVh | ./mpeg2enc -s -r 16 -o $1.m1v else echo -e "$1.m1v file exists.. skipping..\n" fi #Abort if the resulting .m1* files dont exist if [ ! -f $1.m1v ] || [ ! -f $1.m1a ]; then play /usr/share/sounds/scream.wav echo -e "\n** ERROR: One of the .m1* files is missing.. Aborting muxing.\n" exit 0 fi #If an mpeg1 already exists, make sure its big enough, if not, overwrite it TEMP=`ls -la $1.mpeg1 2> /dev/null | awk '{print $5}'` if [ "$TEMP" == "" ] || [ $TEMP -lt 200000000 ]; then #Mux into a mpeg file echo "Determining required bitrate.." ./mplex -f 2 -r 1000 -m 1 -o $1.mpeg1 $1.m1[av] 2> mplex-rate.out > /dev/null RATE1=`grep "best-guess" mplex-rate.out | awk '{print $8}'` RATE=`echo "($RATE1 * .001) + 1" | bc` echo "Required bitrate is: $RATE" # A rate of 1724 is ok on a Denon 2800 echo -e "Beginning to mux files..\n" ./mplex -f 2 -r $RATE -m 1 -o $1.mpeg1 $1.m1[av] else echo -e "The .mpeg1 file already exists and looks valid.\n" fi #Make sure the new mpeg1 file is ok TEMP=`ls -la $1.mpeg1 2> /dev/null | awk '{print $5}'` if [ "$TEMP" == "" ] || [ $TEMP -lt 200000000 ]; then play /usr/share/sounds/scream.wav echo -e "\n** ERROR: the MPEG1 file is missing or is too small.. Aborting imaging.\n" exit 0 else echo -e "The .mpeg1 file looks valid.\n" fi #If an mpeg1 already exists, make sure its big enough, if not, overwrite it TEMP=`ls -la $1.bin 2> /dev/null | awk '{print $5}'` if [ "$TEMP" == "" ] || [ $TEMP -lt 200000000 ]; then #Create the VCD file echo -e "Creating VCD .bin and .cue file..\n" ./vcdimager -p --cue-file=$1.cue --bin-file=$1.bin $1.mpeg1 fi #Make sure the .bin file is present and has a valid file size of at least 250M TEMP=`ls -la $1.bin 2> /dev/null | awk '{print $5}'` if [ "$TEMP" == "" ] || [ $TEMP -lt 250000000 ] || [ ! -f $1.cue ]; then play /usr/share/sounds/scream.wav echo -e "\n\n** ERROR: the .bin or .cue files are missing or is too small. Aborting burn.\n" exit 0 else echo -e "The .bin file looks valid.\n" fi #Burn the CD #Make sure to change the device and speed to match your hardware echo -e "Starting the CD burning cycle..\n" ./cdrdao write --device 1,5,0 --speed 4 $1.cue play /usr/share/sounds/phone.wav #eject /dev/scd1 echo -e "\nDone.\n"