4 echo "Usage: [vcodec=s] [vbitrate=n] [vscale=s] [abitrate=n] [ascale=s] $0 input.avi"
8 if [ -z "$vcodec" ]; then
14 if [ -z "$vbitrate" ]; then
20 if [ -n "$vscale" ]; then
24 if [ -z "$abitrate" ]; then
30 if [ -n "$ascale" ]; then
34 if [ "$vcodec" = x264 ]; then
35 vopts="--bitrate=$vbitrate"
37 elif [ "$vcodec" = x264-hq ]; then
38 vopts="--bitrate=$vbitrate --8x8dct --ref=2 --bframes=3 --b-pyramid --weightb"
40 elif [ "$vcodec" = x264-vhq ]; then
41 vopts="--bitrate=$vbitrate --8x8dct --ref=5 --bframes=3 --b-pyramid --weightb --partitions=all --me=umh"
44 echo "Unknown video codec $vcodec; known codecs are x264[-[v]hq]" >&2
48 if [ -z "$pass" ]; then
55 transcode -i "$1" -x auto,null -y yuv4mpeg,null -k -u 50 $vscale $ascale -o _tmp.y4m || exit 1
57 if [ "$pass" -eq 1 ]; then
58 x264 $vopts --progress -o _tmp.mkv _tmp.y4m || exit 1
60 elif [ "$pass" -eq 2 ]; then
61 x264 $vopts --progress -o /dev/null --pass=1 _tmp.y4m &&
62 x264 $vopts --progress -o _tmp.mkv --pass=2 _tmp.y4m || exit 1
64 elif [ "$pass" -eq 3 ]; then
65 x264 $vopts --progress -o /dev/null --pass=1 _tmp.y4m &&
66 x264 $vopts --progress -o /dev/null --pass=3 _tmp.y4m &&
67 x264 $vopts --progress -o _tmp.mkv --pass=3 _tmp.y4m || exit 1
68 # pass=3 is not a typo!
71 echo "Can only do 1, 2 or 3 passes." >&2
76 transcode -i "$1" -x null,auto -y null,ogg -g 0x0 -b "$abitrate" -m _tmp.ogg &&
78 exec mkvmerge -o output.mkv -A _tmp.mkv _tmp.ogg