4 echo "Usage: [vcodec=s] [vbitrate=n] [vscale=s] [acodec=s] [abitrate=n] [ascale=s] [pass=n] [input_opts=input_opts] [output_opts=output_opts] $0 input [output]"
8 if [ -z "$vcodec" ]; then
12 if [ -z "$vbitrate" ]; then
16 if [ -n "$vscale" ]; then
20 if [ -z "$acodec" ]; then
24 if [ -z "$abitrate" ]; then
28 if [ -z "$pass" ]; then
42 if [ "$vcodec" = mpeg4 ]; then
46 if [ "$vcodec" = mpeg4-hq ]; then
48 vopts="-g 300 -bf 2 -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2"
51 if [ "$vcodec" = mpeg4-vhq ]; then
53 vopts="-g 200 -bf 2 -mbd rd -flags +mv4+aic+qprd+mv0 -flags2 skiprd -trellis 2 -cmp 2 -subcmp 2"
56 if [ "$vcodec" = x264 ]; then
60 if [ "$vcodec" = x264-hq ]; then
65 if [ "$vcodec" = x264-vhq ]; then
67 vopts="-preset veryslow"
70 if [ "$pass" -eq 1 ]; then
71 exec ffmpeg $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -c:a "$acodec" -b:a "$abitrate" $output_opts "$output"
73 elif [ "$pass" -eq 2 ]; then
74 ffmpeg -pass 1 $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -an -f rawvideo -y /dev/null $output_opts &&
75 exec ffmpeg -pass 2 $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -c:a "$acodec" -b:a "$abitrate" $output_opts "$output"
78 echo "Can only do 1 or 2 passes." >&2