5 # Most of this stuff comes straight from MPlayer documentation.
6 # Options are limited only to a small useful subset, if you
7 # want more control, RTFM and DIY.
13 # Author: Reynaldo H. Verdejo Pinochet <reynaldo@opendot.cl>
15 # Script: MPlayer Sources. Anything supported to vcd/svcd pal/ntsc
19 # sugests: vcdimager / cdrecord
21 # Thanks to: Carlos Navarro Salas - name author ;)
38 EDLFILENAME
="pass.edl"
44 OPTIONS
="INPUTFILENAME TARGET ENCQ ABPS VBPS NORM SPLIT TOLERANCE OUTNAME"
49 echo "usage $MYNAME inputfile [options]"
51 echo "Options: [Default value]"
53 echo "-t Target svcd|vcd [svcd]"
54 echo "-q Encoding quality 0|1|2 [2]"
55 echo "-a Audio bitrate in kbps [224]"
56 echo "-v Video bitrate in kbps [2000 For SVCD, 1150 For VCD]"
57 echo "-n Norm NTSC|PAL [NTSC]"
58 echo "-d Divide/split movie at given times time1:time2:... [no split]"
59 echo "-s Shitty TV screen tolerance %, afects subtitle positioning [85]"
60 echo "-u Subtitle file name [No subtitle]"
61 echo "-o Output basename [mencodedvcd]"
63 echo "In case you want to use -a/-v please read:"
64 echo "http://www.mplayerhq.hu/DOCS/HTML/en/menc-feat-vcd-dvd.html"
68 function test_needed
()
72 if [ -z "`which $i`" ]; then
73 echo "[ERROR] mencoder not found in $PATH!"
80 function test_sugested
()
83 for i
in vcdimager cdrecord
; do
84 if [ -z "`which $i`" ]; then
85 echo "[WARNING] $i not found in $PATH!"
86 echo "You'll likely need it after we finish."
97 echo "[ERROR] Input filename parameter is mandatory."
114 while [ "$1"x
!= "x" ]; do
158 echo "[STATUS] Will re-encode using the following parameters:"
160 for i
in $OPTIONS ; do
164 # Parameter Sanity Check ###########################################
165 # We need to check supplied params against known format constraints
166 ####################################################################
168 if [ $TARGET = "svcd" ]; then
169 if [ $ABPS -gt 384 ]; then
170 echo "[ERROR] SVCD maximum abitrate is 384kbps."
173 if [ $VBPS -gt 2600 ]; then
174 echo "[ERROR] SVCD maximum vbitrate is 2600kbps."
177 else [ $TARGET = "vcd" ]
178 if [ $ABPS -eq 224 ]; then
179 echo "[ERROR] VCD abitrate must be 224kbps."
182 if [ $VBPS -gt 1150 ]; then
183 echo "[ERROR] VCD maximum vbitrate is 1150kbps."
188 # Set encoding options ##############################################
190 if [ $TARGET = "svcd" ]; then
196 if [ $NORM = "NTSC" ]; then
202 else [ $NORM = "PAL" ]
208 else [ $TARGET = "vcd" ]
214 if [ $NORM = "NTSC" ]; then
219 else [ $NORM = "PAL" ]
227 # Start reencoding ###################################################
231 if [ $
(($HAVESUB+1)) -eq 1 ]; then
232 SUBTITLESTRING
="/dev/null"
234 SUBTITLESTRING
="$SUBFILENAME"
237 if [ $SPLIT == "0" ]; then
241 if [ -e $EDLFILENAME ]; then
243 echo "The -d option needs to generate a temporary file called"
244 echo "$EDLFILENAME. You already have one in this directory,"
245 echo "please remove/rename it and run $MYNAME again."
249 EDLSTRING
=$
(echo $SPLIT |
sed -e s
/:/' '/g
)
250 EDLARRAY
=($EDLSTRING)
251 CICLES
=$
(echo $EDLSTRING |
wc -w)
252 TIMESTRING
="-edl $EDLFILENAME -hr-edl-seek"
257 for j
in $
(seq 0 $CICLES); do
259 NEWNAME
=$OUTNAME"_PART"$j".mpg"
261 echo "Making $NEWNAME, wish me luck ;-)"
264 # Create EDLFILENAME #################################################
266 if [ $CICLES -ge 1 ]; then
267 for i
in $
(seq 0 $CICLES)
269 if [ $i -eq $j ]; then
270 if [ $j -ne 0 ]; then
271 echo "0 ${EDLARRAY[$(($i-1))]} 0" > $EDLFILENAME
273 if [ $i -ne $CICLES ]; then
274 echo "${EDLARRAY[$(($i))]} 999999 0" >> $EDLFILENAME
280 # Mencoder Time ;-) ###################################################
283 -ovc lavc
-oac lavc
-vf expand=:::::$RATIOX/$RATIOY:1,scale
=$SCALEX:$SCALEY,harddup \
284 -srate 44100 -af lavcresample
=44100 -lavcopts acodec
=mp2
:abitrate
=$ABPS:vcodec
=$VCODEC:\
285 vbitrate
=$VBPS:keyint
=$KEYINT:mbd
=$ENCQ:vrc_buf_size
=$VRCBUFSIZE:vrc_maxrate
=$VRCMAXRATE:\
286 vrc_minrate
=$VRCMINRATE:vi_qfactor
=0.1:vi_qoffset
=1.5:aspect
=$RATIOX/$RATIOY -of mpeg \
287 -mpegopts format
=$FORMAT$TELECINE -sub $SUBTITLESTRING -subpos $TOLERANCE -subwidth \
288 $TOLERANCE -ofps $OFPS $TIMESTRING -o $NEWNAME $INPUTFILENAME
290 echo "Encoding of $NEWNAME finished."
291 echo "Run vcdimager -t svcd/vcd $NEWNAME and burn with cdrecord."
295 echo "$(($CICLES+1)) VCD/SVCD file(s) created!!!"
296 echo "Happy to be of some help ;-) have fun."