]> git.phdru.name Git - audio-cdr-video.git/blob - video/ff_encode
990e5c332b80d95b52bf62c33a8b2124c51bed43
[audio-cdr-video.git] / video / ff_encode
1 #! /bin/sh
2
3 if [ -z "$1" ]; then
4    echo "Usage: [vcodec=s] [vbitrate=n] [vscale=s] [aid=n] [acodec=s] [abitrate=n] [ascale=s] [pass=n] [input_opts=input_opts] [output_opts=output_opts] $0 input.avi"
5    exit 1
6 fi
7
8 if [ -z "$vcodec" ]; then
9    vcodec=mpeg4
10 fi
11
12 if [ -z "$vbitrate" ]; then
13    vbitrate=1600k
14 fi
15
16 if [ -n "$vscale" ]; then
17    vscale="-s $vscale"
18 fi
19
20 if [ -z "$acodec" ]; then
21    acodec=libmp3lame
22 fi
23
24 if [ -z "$abitrate" ]; then
25    abitrate=256k
26 fi
27
28 if [ -z "$pass" ]; then
29    pass=1
30 fi
31
32 input="$1"
33 shift
34
35 if [ "$vcodec" = mpeg4-hq ]; then
36    vcodec=mpeg4
37    vopts="-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2"
38 fi
39
40 if [ "$pass" -eq 1 ]; then
41    exec ffmpeg $input_opts -i "$input" -f avi -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -g 300 -bf 2 -c:a "$acodec" -b:a "$abitrate" $output_opts output.avi
42
43 elif [ "$pass" -eq 2 ]; then
44    ffmpeg -pass 1 $input_opts -i "$input" -f avi -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -g 300 -bf 2 -an -f rawvideo -y /dev/null $output_opts &&
45    exec ffmpeg -pass 2 $input_opts -i "$input" -f avi -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -g 300 -bf 2 -c:a "$acodec" -b:a "$abitrate" $output_opts output.avi
46
47 else
48    echo "Can only do 1 or 2 passes." >&2
49    exit 1
50 fi