| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
usage() |
| 4 |
{ |
| 5 |
echo "Usage: transcode -S|-V [-T] [-s mins] [-b bitrate] [-F framerate] [-o dstfile] srcfile ..." |
| 6 |
echo "o - output file root name" |
| 7 |
echo "b - bitrate for video in kbps" |
| 8 |
echo "s - sleep for specified number of minutes before starting work" |
| 9 |
echo "T - Use test encoder" |
| 10 |
echo "S - Transcode for SVCD or" |
| 11 |
echo "V - Transcode for VCD" |
| 12 |
echo "F - fhe frame rate can also be specified, choose one if needed: " |
| 13 |
mpeg2enc -F -h |
| 14 |
exit 0 |
| 15 |
} |
| 16 |
|
| 17 |
# Use this commented-out version if you haven't got sox and toolame |
| 18 |
#MP2ENC="nice -n 29 wav2mp2 -v -o" |
| 19 |
MPEG2ENC=mpeg2enc |
| 20 |
MPLEX=mplex |
| 21 |
if [ $# -lt 3 ] |
| 22 |
then |
| 23 |
usage |
| 24 |
fi |
| 25 |
outpat=".%d" |
| 26 |
outfile=transcoded |
| 27 |
bitrate="" |
| 28 |
sleep=0 |
| 29 |
decode="YUVh" |
| 30 |
while getopts ":o:b:s:F:SVTXh" opt |
| 31 |
do |
| 32 |
case $opt in |
| 33 |
s) sleep=$OPTARG |
| 34 |
;; |
| 35 |
b) bitrate="-b $OPTARG" |
| 36 |
;; |
| 37 |
o) outfile=$OPTARG |
| 38 |
;; |
| 39 |
F) framerate="-F $OPTARG" |
| 40 |
;; |
| 41 |
T) |
| 42 |
echo Using test encoder |
| 43 |
MPEG2ENC="mpeg2enc.test" |
| 44 |
MPLEX=mplex.test |
| 45 |
;; |
| 46 |
h) |
| 47 |
echo hi-res mode |
| 48 |
MPEGOPTS="$MPEGOPTS -H" |
| 49 |
;; |
| 50 |
X) |
| 51 |
echo Using test encoder max speed |
| 52 |
MPEGOPTS="$MPEGOPTS -4 1 -2 1" |
| 53 |
;; |
| 54 |
V) |
| 55 |
echo Generating VCD stream |
| 56 |
MPEGOPTS="$MPEGOPTS -f 1" |
| 57 |
decode="YUVh" |
| 58 |
;; |
| 59 |
S) |
| 60 |
echo Generating SVCD stream |
| 61 |
MPEGOPTS="$MPEGOPTS -f 4 -q 9 -P -V 200" |
| 62 |
bitrate="-b 2500" |
| 63 |
decode="YUVs" |
| 64 |
;; |
| 65 |
?) usage |
| 66 |
;; |
| 67 |
esac |
| 68 |
done |
| 69 |
if [ x"$MPEGOPTS" = "x" ] |
| 70 |
then |
| 71 |
echo "Must specify -V or -S!" |
| 72 |
useage |
| 73 |
fi |
| 74 |
shift `expr $OPTIND - 1` |
| 75 |
sleep `expr $sleep * 60` |
| 76 |
|
| 77 |
cat $* | mpeg2dec -s -o $decode | \ |
| 78 |
${MPEG2ENC} ${MPEGOPTS} $bitrate $framerate -o $outfile.m1v |
| 79 |
|
| 80 |
cat $* | extract_a52 - -s | a52dec -m wav | \ |
| 81 |
sox -t wav /dev/stdin -t wav -r 44100 /dev/stdout | \ |
| 82 |
toolame -p 2 -b 224 /dev/stdin $outfile.mp2 |
| 83 |
|
| 84 |
# Eventually mux-ing goes here! |
| 85 |
|