[Mplayer-felhasznalok] divx2svcd

VMiklos mamajom at axelero.hu
Wed Jan 7 20:25:27 CET 2004


On Tue, 6 Jan 2004, Suity Zsolt wrote:

> Eh, talan nem is erdemes ezzel kinlodni, minden mas jol megy. Akinek ez miatt
> nem megy nevezze at ;)

a ganyolasnak is van hatara! erre nem gondoltam, de egy tisztesseges
scriptnek kezelnie kell az ilyeneket! eleg sokat vacakoltam, de most
mar nekem muxik. kuldom, jo lenne tesztelni, hogy mashol is muxik-e

az uj verzio 0.4.5

udv

---
       __________     VMiklos / FapadOS & EL Team
  ____/__/___|___\__. E-mail: mainroot at freemail dot hu
O__O  _ |   |   _  |  Homepage: http://www.vmiklos.tk
'--`-(_)'---'--(_)-'  gpg --keyserver hkp://pgp.mit.edu --recv-keys 03915096

-------------- next part --------------
#!/bin/bash

# (c) 2003 Vajna Miklos <mainroot at freemail.hu>
# divx2svcd for MPlayer 1.0pre3+dumpvideo patch
# distributed under GPL License

# MPlayer avariable at
# http://www1.mplayerhq.hu/MPlayer/releases/MPlayer-1.0pre3.tar.bz2
# dumpvideo patch at
# http://vmiklos.uw.hu/divx2svcd/mplayer-1.0pre3-dumpvideo.diff

# version 0.4.5

###changelog###
#nobody cares about it :-)
cat >/dev/null <<EOF
0.4.5
- support for filenames including spaces

0.4.4
- support for checking for all application this script uses
- this changelog

0.4.3
- advanced detectation of movie aspect (mpeg4 codec, mpeg container)

0.4.2
- advanced vf options for movies with non-standard aspect

0.4.1
- checking for sub avariable

0.4.0
- support for tcmplex-panteltje
- support for libavcodec audio encoder


0.3.1-0.3.2
- small fixes

0.3
- almost totally rewritten from scratch
  based on the idea of Denes Balatoni <pnis at coder.hu>
- support for toolame instead of mp2enc
- suppert for libavcodec mpeg2video codec instead of mpeg2enc


0.2
- support for tcmplex instead of mplex

0.1rc2-rc4
- small bugfixes

0.1rc1
- initial release

EOF


###preparing###
#help

function usage()
{
	cat <<EOF
Usage: $0 input_avi [options]

Options:
-b|--bitrate	bitrate of mp2 video stream [1600]
-s|--cdsize	size of the cd we split the video to [795]
-h|--help	this help screen
EOF

}

#initializating constants
bitrate=1200
cdmeret=795

#checking for bc
which bc >/dev/null 2>&1
bcbin=`which bc 2>/dev/null`
if [ $? != 0 ]; then
	cat <<EOF
ERROR: Can't find bc. You can download it at
ftp://ftp.ibiblio.org/pub/gnu/bc/bc-1.06.tar.gz
EOF
exit 1
fi

#checking for vcdimager
which vcdimager >/dev/null 2>&1
bcbin=`which vcdimager 2>/dev/null`
if [ $? != 0 ]; then
	cat <<EOF
ERROR: Can't find vcdimager. You can download it at http://www.vcdimager.org
/pub/vcdimager/vcdimager-0.7_UNSTABLE/vcdimager-0.7.14.tar.gz
EOF
exit 1
fi

#checking which mplex utility we have to use
which tcmplex-panteltje >/dev/null 2>&1
if [ $? = 0 ]; then
	tcp_path=`which tcmplex-panteltje 2>&1`
else
	tcp_path="x"
fi
which tcmplex >/dev/null 2>&1
if [ $? = 0 ]; then
	tc_path=`which tcmplex 2>&1`
else
	tc_path="x"
fi

if [ -x $tcp_path ]; then
	tcbin=tcmplex-panteltje
	tcopt=-0
elif [ -x $tc_path ]; then
	tcbin=tcmplex
	tcopt=-p
else
	cat <<EOF
ERROR: Can't find any sutable mplex utility. You can download
tcmplex-panteltje at http://sunsite.rediris.es/
sites2/ibiblio.org/linux/apps/video/tcmplex-panteltje-0.3.tgz
EOF
exit 1
fi

#pharsing parameters

if [ $# -le 0 ]; then
	echo "Missing parameter!"
	usage
	exit 1
fi

case $1 in
	-h)
		usage
		exit 1
	;;
	-*)
		echo "Missing parameter!"
		usage
		exit 1
	;;
	*)
		input=`echo $1 |sed 's/\\ / /'`
		if [ "$input" == "`basename "$input"`" ]; then
		        input="`pwd`/$1"
		fi
		nev=`basename "$input" .avi`
		shift 1
	;;
esac

while [ "$1"x != "x" ]; do
   case $1 in
      -b|--bitrate)
        bitrate=$2
	shift 1
        ;;
      -s|--cdsize)
      	cdmeret="$2"
	shift 1
	;;
      -h|--help)
      usage
        exit 0
	;;
   esac
   shift 1
done

#checking for sub avariable

if [ -f "$nev.sub" ]; then
	subopts=$nev.sub
else
	subopts=''
fi

#checking for what height needed
inputwidth=`mplayer -vo null -ao null "$input" -frames 1 |grep '=>'|cut -d ' ' -f 5|cut -d x -f 1`
inputheight=`mplayer -vo null -ao null "$input" -frames 1 |grep '=>'|cut -d ' ' -f 5|cut -d x -f 2`
svcdaspect=`echo -e "scale=10\n1.596/($inputwidth/$inputheight)"|bc /dev/stdin`
height=`echo -e "scale=10\n$svcdaspect*480"|bc /dev/stdin|cut -d . -f 1`

#checking for ratios less than 1.33
istoohigh=`expr $height \> 577`
if [ "$istoohigh" = 1 ]; then
	height=576
fi

#find out the vf options
if [ "$height" = 576 ]; then
	vfopts='-vf scale=480:576'
else
	#-vf processes filters in reverse order
	exy=`echo -e "scale=10\n(576-$height)/2"|bc /dev/stdin|cut -d . -f 1`
	vfopts="-vf scale=480:$height,expand=480:576:0:$exy:1"
	echo "using filter options: '$vfopts'"
fi


###start working###
#encoding
mencoder -ofps 25 -oac lavc "$input" -ovc lavc -lavcopts vcodec=mpeg2video:vbitrate=$bitrate:acodec=mp2:abitrate=128:keyint=25:aspect=4/3 -o "${nev}2.avi" -sub "$subopts" -srate 44100 -channels 2 $vfopts

#splitting
mplayer -dumpvideo -dumpfile "$nev.m2v" "${nev}2.avi"
mplayer -dumpaudio -dumpfile "$nev.mp2" "${nev}2.avi"
rm "${nev}2.avi"
echo "maxFileSize = $cdmeret" > template
$tcbin -i "$nev.m2v" $tcopt "$nev.mp2" -o "$nev.mpg" -m s -F template
rm template
rm "$nev.m2v" "$nev.mp2"

#creating images
ls -N "$nev"*mpg | while read i
do
	nev2=`basename "$i" .mpg`
	vcdimager -t svcd -c "$nev2.cue" -b "$nev2.bin" "$i"
done
rm "$nev"*mpg


More information about the MPlayer-felhasznalok mailing list