Mercurial > mplayer.hg
comparison TOOLS/mencvcd @ 5686:00ac1397ecb7
- new option "-burnonly": burn only the preformated bin images
- new option "-vbr": sets video bitrate
- removes mpg file after mastering cd image
(mplayer can read bin images!)
- bug fixes
author | atmos4 |
---|---|
date | Thu, 18 Apr 2002 17:41:54 +0000 |
parents | b62460b1db74 |
children | e77da1c93ef7 |
comparison
equal
deleted
inserted
replaced
5685:a56c9404364e | 5686:00ac1397ecb7 |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 # | 2 # |
3 # Version: 0.1.2 | 3 # Version: 0.1.3 |
4 # | 4 # |
5 # Licence: GPL | 5 # Licence: GPL |
6 # | 6 # |
7 # 2002/04/14 Jürgen Hammelmann <juergen.hammelmann@gmx.de> | 7 # 2002/04/14 Jürgen Hammelmann <juergen.hammelmann@gmx.de> |
8 # | 8 # |
17 ################################################################################ | 17 ################################################################################ |
18 # | 18 # |
19 # 2002/04/11 v0.1.0: first version | 19 # 2002/04/11 v0.1.0: first version |
20 # 2002/04/12 v0.1.1: | 20 # 2002/04/12 v0.1.1: |
21 # 2002/04/14 v0.1.2: | 21 # 2002/04/14 v0.1.2: |
22 # - handles now multiple vcd's | 22 # - handles now multiple vcd's |
23 # - support's mp3 audio as option | 23 # - support's mp3 audio as option |
24 # - use of mp2enc/lame instead of toolame because of support | 24 # - use of mp2enc/lame instead of toolame because of support |
25 # of resampling and mp3 | 25 # of resampling and mp3 |
26 # 2002/04/16 v0.1.3: | |
27 # - new option "-burnonly" | |
28 # - new option "-vbr" | |
29 # - removes mpg file after mastering cd image | |
30 # (mplayer can read bin images!) | |
31 # - bug fixes | |
26 # | 32 # |
27 ################################################################################ | 33 ################################################################################ |
28 # | 34 # |
29 # global config section, change them to your needs! | 35 # global config section, change them to your needs! |
30 | 36 |
38 AUDIO="audiodump.wav" | 44 AUDIO="audiodump.wav" |
39 VIDEO="stream.yuv" | 45 VIDEO="stream.yuv" |
40 ################################################################################ | 46 ################################################################################ |
41 | 47 |
42 function usage() { | 48 function usage() { |
43 echo "usage: $HOWCALLED <filename> [options] [mplayer options]" | 49 echo "usage: $HOWCALLED <name> [options] [mplayer options]" |
44 echo | 50 echo |
45 echo "$HOWCALLED options:" | 51 echo "$HOWCALLED options:" |
46 echo | 52 echo |
47 echo "-h|-? help" | 53 echo "-h|-? help" |
48 echo "-w outputs in wide screen format 16:9" | 54 echo "-w outputs in wide screen format 16:9" |
49 echo "-abr <n> output audio bitrate in kbs [224]" | 55 echo "-abr <n> output audio bitrate in kbs [224]" |
50 echo "-asr <n> output audio sample rate in Hz [48000]" | 56 echo "-asr <n> output audio sample rate in Hz [48000]" |
51 echo "-blank cleans cd-rw before burning" | 57 echo "-blank cleans cd-rw before burning" |
58 echo "-burnonly burn only the premastered <name>*.cue/<name>*.bin images" | |
52 echo "-cdsize <n> maximal size of cd images [646]" | 59 echo "-cdsize <n> maximal size of cd images [646]" |
53 echo "-denoise denoises mpeg stream" | 60 echo "-denoise denoises mpeg stream" |
54 echo "-noburn disables burning" | 61 echo "-noburn disables burning" |
55 echo "-mp3 outputs audio in mp3 instead of mp2 format" | 62 echo "-mp3 outputs audio in mp3 instead of mp2 format" |
56 echo "-mpg don't encode from source, multiplex/burn" | 63 echo "-mpg don't encode from source, multiplex/burn" |
57 echo " only the encoded mpg stream" | 64 echo " only the encoded mpg stream" |
58 echo "-vcdout encode to VCD format [default]" | 65 echo "-svcdout encode to SVCD format [VCD default]" |
59 echo "-svcdout encode to SVCD format" | 66 echo "-vbr <n> output video bitrate in kbs [VCD:1152, SVCD:2500]" |
60 echo | 67 echo |
61 echo "example:" | 68 echo "example:" |
62 echo "'$HOWCALLED crazy -dvd 3 -w' encodes and burns dvd title 3 to VCD in 16:9." | 69 echo "'$HOWCALLED crazy -dvd 3 -w' encodes and burns dvd title 3 to VCD in 16:9." |
63 } | 70 } |
64 | 71 |
79 # some inits | 86 # some inits |
80 params="" | 87 params="" |
81 wide="" | 88 wide="" |
82 blank=0 | 89 blank=0 |
83 burn=1 | 90 burn=1 |
91 burnonly=0 | |
84 mp3=0 | 92 mp3=0 |
85 mkstream=1 | 93 mkstream=1 |
86 abr=224 | 94 abr=224 |
87 abrset=0 | 95 abrset=0 |
88 asr=44100 | 96 asr=44100 |
97 vbr=1152 | |
98 vbrset=0 | |
89 denoise="cat -" | 99 denoise="cat -" |
90 norm="VCD" | 100 norm="VCD" |
91 mplexnorm="-f 2 -m 1 -V" | 101 mplexnorm="-f 2 -m 1 -V" |
92 max=646 | 102 max=646 |
93 mpegnorm="-f 2 -b 1152 -B 260" | 103 mpegnorm="-f 2 -b $vbr -B 260" |
94 imaget="-t vcd2" | 104 imaget="-t vcd2" |
105 | |
95 while [ "$1"x != "x" ]; do | 106 while [ "$1"x != "x" ]; do |
96 case $1 in | 107 case $1 in |
97 -w) | 108 -w) |
98 wide="-M WIDE2STD" | 109 wide="-M WIDE2STD" |
99 ;; | 110 ;; |
118 blank=1 | 129 blank=1 |
119 ;; | 130 ;; |
120 -noburn) | 131 -noburn) |
121 burn=0 | 132 burn=0 |
122 ;; | 133 ;; |
134 -burnonly) | |
135 burnonly=1 | |
136 burn=1 | |
137 ;; | |
123 -mp3) | 138 -mp3) |
124 mp3=1 | 139 mp3=1 |
125 ;; | 140 ;; |
126 -mpg) | 141 -mpg) |
127 mkstream=0 | 142 mkstream=0 |
128 ;; | 143 ;; |
129 -denoise) | 144 -denoise) |
130 denoise="yuvdenoise" | 145 denoise="yuvdenoise" |
131 ;; | 146 ;; |
132 -vcdout) | |
133 norm="VCD" | |
134 mplexnorm="-f 2 -m 1 -V" | |
135 mpegnorm="-f 2 -b 1152 -B 260" | |
136 imaget="-t vcd2" | |
137 ;; | |
138 -svcdout) | 147 -svcdout) |
139 norm="SVCD" | 148 norm="SVCD" |
140 mplexnorm="-f 4 -m 2 -V" | 149 ;; |
141 mpegnorm="-f 4 -b 2500 -B 260" | 150 -vbr) |
142 imaget="-t svcd" | 151 vbr=$2 |
152 vbrset=1 | |
153 shift 1 | |
143 ;; | 154 ;; |
144 *) | 155 *) |
145 params="$params $1" | 156 params="$params $1" |
146 ;; | 157 ;; |
147 esac | 158 esac |
148 shift 1 | 159 shift 1 |
149 done | 160 done |
150 | 161 |
151 # some configs | 162 # some configs |
152 if [ -n "$wide" ]; then | 163 if [ "$norm" == "SVCD" ]; then |
153 if [ "$norm" == "SVCD" ]; then | 164 [ $vbrset -eq 0 ] && vbr=2500 |
154 wide="" | 165 mplexnorm="-f 5 -m 2 -V" |
155 mpegnorm="$mpegnorm -a 3" | 166 mpegnorm="-f 5 -b $vbr -B 260 -a 2" |
156 fi | 167 imaget="-t svcd" |
157 fi | 168 fi |
158 | 169 |
159 # with mp3 audio set the default audio bitrate to 128 kbs | 170 # with mp3 audio set the default audio bitrate to 128 kbs |
160 if [ $mp3 -eq 1 -a $abrset -eq 0 ]; then | 171 [ $mp3 -eq 1 -a $abrset -eq 0 ] && abr=128 |
161 abr=128 | |
162 fi | |
163 | 172 |
164 # audio sample rate in kHz | 173 # audio sample rate in kHz |
165 ((a=$asr / 1000)) | 174 ((a=$asr / 1000)) |
166 ((b=$asr % 1000)) | 175 ((b=$asr % 1000)) |
167 [ $b -le 9 ] && b="00$b00" | 176 [ $b -le 9 ] && b="00$b00" |
168 [ $b -le 99 ] && b="0$b00" | 177 [ $b -le 99 ] && b="0$b00" |
169 kasr="$a.$b" | 178 kasr="$a.$b" |
170 | 179 |
171 # encode streams | 180 if [ $burnonly -eq 0 ]; then |
172 if [ $mkstream -eq 1 ]; then | 181 # encode streams |
173 # start mplayer | 182 if [ $mkstream -eq 1 ]; then |
174 mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader $params & | 183 # start mplayer |
175 | 184 mplayer -noframedrop -vo yuv4mpeg -ao pcm -waveheader \ |
176 # mjpegtools | 185 -osdlevel 0 $params & |
177 ($denoise < $VIDEO | \ | 186 |
178 yuvscaler -v 0 $wide -O $norm | \ | 187 # mjpegtools |
179 mpeg2enc -v 0 -s $mpegnorm -S $max -g 6 -G 15 -r 16 -o $NAME.mpv) & | 188 ($denoise < $VIDEO | \ |
189 yuvscaler -v 0 $wide -O $norm | \ | |
190 mpeg2enc -v 0 -s $mpegnorm -S $max -g 6 -G 15 -r 16 -o $NAME.mpv) & | |
180 | 191 |
181 # wait for finishing the subprocesses | 192 # wait for finishing the subprocesses |
182 wait | 193 wait |
183 | 194 |
184 if [ $mp3 -eq 0 ]; then | 195 if [ $mp3 -eq 0 ]; then |
185 # mp2enc/lame can't read audiodump.wav directly from named pipe, | 196 # mp2enc/lame can't read audiodump.wav directly from named pipe, |
186 # we have to read the whole file. | 197 # we have to read the whole file. |
187 mp2enc -b $abr -r $asr -o $NAME.mpa < $AUDIO | 198 mp2enc -b $abr -r $asr -o $NAME.mpa < $AUDIO |
188 else | 199 else |
189 lame -b $abr --resample $kasr - $NAME.mpa < $AUDIO | 200 lame -b $abr --resample $kasr - $NAME.mpa < $AUDIO |
201 fi | |
190 fi | 202 fi |
203 | |
204 # remove wav file, won't need anymore! | |
205 rm -f $AUDIO | |
206 | |
207 # multiplex streams | |
208 [ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1 | |
209 rm -f ${NAME}*.mpg | |
210 mplex $mplexnorm $NAME.mpv $NAME.mpa -o ${NAME}%d.mpg | |
211 | |
212 # create cd images | |
213 for mpg in ${NAME}*.mpg; do | |
214 [ -f $mpg ] || exit 1 | |
215 cue="`basename $mpg .mpg`.cue" | |
216 bin="`basename $mpg .mpg`.bin" | |
217 rm -f $cue $bin | |
218 vcdimager $imaget -c $cue -b $bin $mpg | |
219 [ -f $bin -a -f $cue ] && rm -f $mpg | |
220 done | |
221 | |
222 # end of streaming/mastering | |
191 fi | 223 fi |
192 | 224 |
193 # remove pipe and wav file, won't need anymore! | 225 # remove pipe, won't need anymore! |
194 rm -f $VIDEO | 226 rm -f $VIDEO |
195 rm -f $AUDIO | |
196 | |
197 # multiplex streams | |
198 [ -f $NAME.mpv -a -f $NAME.mpa ] || exit 1 | |
199 rm -f ${NAME}*.mpg | |
200 mplex $mplexnorm $NAME.mpv $NAME.mpa -o ${NAME}%d.mpg | |
201 | |
202 # create cd images | |
203 for mpg in ${NAME}*.mpg; do | |
204 [ -f $mpg ] || exit 1 | |
205 cue="`basename $mpg .mpg`.cue" | |
206 bin="`basename $mpg .mpg`.bin" | |
207 rm -f $cue $bin | |
208 vcdimager $imaget -c $cue -b $bin $mpg | |
209 done | |
210 | 227 |
211 # burn the (s)vcd's | 228 # burn the (s)vcd's |
212 [ $burn -eq 0 ] && exit 0 | 229 [ $burn -eq 0 ] && exit 0 |
213 | 230 |
214 for cue in ${NAME}*.cue; do | 231 for cue in ${NAME}*.cue; do |