Fixed a bug where delete didn't work from a page where you supplied a "path".
[recordtv.git] / scripts / convert_ts_to_flv.sh
blob3fdc28e6cf2f545c855148fdca29bb245695f9d8
1 #!/bin/bash
3 # Usage:
5 # ./convert_ts_to_flv.sh a/file.ts b/c/conv_unproc.flv b/c/conv.flv a/old
7 # Converts the supplied MPEG-2 ts file to FLV format.
10 TS_FILENAME="$1"
11 FLV_UP_FILENAME="$2"
12 FLV_FILENAME="$3"
13 OLD_DIR="$4"
15 SIZE=566x330
17 UP_SUFFIX=_before_flvtool2
19 if [ ! -f "$FLV_UP_FILENAME" -a \
20 ! -f "$FLV_FILENAME" ]; then
22 echo "Converting $TS_FILENAME"
23 ffmpeg -re -r 25 -y -i "$TS_FILENAME" -b 900k -async 1000 -ar 44100 -s $SIZE -f flv -ar 22050 -acodec mp3 "$FLV_UP_FILENAME" 2> ffmpeg_stderr.txt
25 RETVAL=$?
27 #echo 'mkdir -p "'$OLD_DIR'"'
28 mkdir -p "$OLD_DIR"
29 #echo 'mv "'$TS_FILENAME'" "'$OLD_DIR'"'
30 mv "$TS_FILENAME" "$OLD_DIR"
31 #echo 'mv returned ' $?
33 if [[ $RETVAL != 0 ]]; then
35 echo '$ ffmpeg -re -r 25 -y -i "'$TS_FILENAME'" -b 900k -async 1000 -ar 44100 -s '$SIZE' -f flv -ar 22050 -acodec mp3 "'$FLV_FILENAME'"'
37 cat ffmpeg_stderr.txt
39 echo "Error: ffmpeg returned '"$RETVAL"'"
41 exit 2
42 }; fi
44 rm ffmpeg_stderr.txt
46 else
48 if [ -f "$FLV_FILENAME" ]; then
50 echo "Error: .flv filename already exists: " $FLV_FILENAME
51 exit 5
53 elif [ -f "$FLV_UP_FILENAME" ]; then
55 echo "unprocessed filename already exists. Just converting it: " $FLV_UP_FILENAME
57 #echo 'mkdir -p "'$OLD_DIR'"'
58 mkdir -p "$OLD_DIR"
59 #echo 'mv "'$TS_FILENAME'" "'$OLD_DIR'"'
60 mv "$TS_FILENAME" "$OLD_DIR"
61 #echo 'mv returned ' $?
63 else
65 echo "Error: did not convert but neither .flv nor unprocessed files exist."
66 exit 6
67 }; fi
68 }; fi
71 if [ -f $FLV_UP_FILENAME ]; then
73 if [ ! -f $FLV_FILENAME ]; then
75 /home/andy/cvs/flvtoolpp/flvtoolpp "$FLV_UP_FILENAME" "$FLV_FILENAME"
76 RETVAL=$?
78 if [[ $RETVAL == 0 ]]; then
80 rm "$FLV_UP_FILENAME"
82 else
84 echo "Error: flvtoolpp returned non-zero!"
85 exit 3
86 }; fi
88 else
90 echo "Error: $FLV_UP_FILENAME would clash with existing file $FLV_FILENAME!"
91 exit 4
92 }; fi
94 else
96 echo "Error: unprocessed file does not exist after ffmpeg."
97 exit 7
98 }; fi