Alternative recording and conversion scripts.
[recordtv.git] / scripts / convert_ts_to_mp2.sh
blobdb361e7177914ac2db9be3500c1dbe84740352e1
1 #!/bin/bash
3 # Usage:
5 # ./convert_ts_to_mp2.sh a/file.ts b/c/prog_converting.avi b/c/prog.avi a/old
7 # Converts the supplied MPEG-2 ts file to MPEG-2 640x480 format.
10 TS_FILENAME="$1"
11 CONV_FILENAME="$2"
12 MP2_FILENAME="$3"
13 OLD_DIR="$4"
15 SIZE=640x480
17 if [ ! -f "$MP2_FILENAME" ]; then
19 #echo "Converting $TS_FILENAME to MPEG-2 .avi"
20 echo $TS_FILENAME
22 #echo '$ mencoder -quiet '"'$TS_FILENAME'"' -o '"'$CONV_FILENAME'"' -vf pp=li,scale=640:480 -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=1200'
24 mencoder -quiet "$TS_FILENAME" -o "$CONV_FILENAME" -vf pp=li,scale=640:480 -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=1200 > mencoder_out.txt 2>&1
26 RETVAL=$?
28 mkdir -p "$OLD_DIR"
29 mv "$TS_FILENAME" "$OLD_DIR"
31 if [[ $RETVAL != 0 ]]; then
33 echo '$ mencoder -quiet '"'$TS_FILENAME'"' -o '"'$CONV_FILENAME'"' -vf pp=li,scale=640:480 -oac mp3lame -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=1200'
35 cat mencoder_out.txt
37 echo "** Error: mplayer returned '"$RETVAL"' **"
39 echo "echo Conversion of "$TS_FILENAME" failed." | at now
41 exit 2
42 }; fi
44 mv "$CONV_FILENAME" "$MP2_FILENAME"
46 rm mencoder_out.txt
48 else
50 echo "** Error: .mp2 filename already exists: " $MP2_FILENAME " **"
51 exit 5
52 }; fi