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] [output=output.avi] [crop=w:h:x:y] $0 input1 [input2...]"
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
32 if [ -n "$crop" ]; then
39 input=concat:"`echo \"$@\" | sed 's/ /|/g'`"
42 if [ -z "$output" ]; then
46 if [ "$vcodec" = mpeg4 ]; then
49 elif [ "$vcodec" = mpeg4-hq ]; then
51 vopts="-g 300 -bf 2 -mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2"
53 elif [ "$vcodec" = mpeg4-vhq ]; then
55 vopts="-g 200 -bf 2 -mbd rd -flags +mv4+aic+qprd+mv0 -flags2 skiprd -trellis 2 -cmp 2 -subcmp 2"
57 elif [ "$vcodec" = x264 ]; then
60 elif [ "$vcodec" = x264-hq ]; then
64 elif [ "$vcodec" = x264-vhq ]; then
66 vopts="-preset veryslow"
69 echo "Unknown video codec $vcodec; known codecs are {mpeg4,x264}[-[v]hq], copy" >&2
73 if [ "$pass" -eq 1 ]; then
74 exec ffmpeg -threads auto $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -c:a "$acodec" -b:a "$abitrate" $output_opts $crop "$output"
76 elif [ "$pass" -eq 2 ]; then
77 ffmpeg -pass 1 -threads auto $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -an -f rawvideo -y /dev/null $output_opts $crop &&
78 exec ffmpeg -pass 2 -threads auto $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -c:a "$acodec" -b:a "$abitrate" $output_opts $crop "$output"
81 echo "Can only do 1 or 2 passes." >&2