]> git.phdru.name Git - audio-cdr-video.git/blob - video/ff_encode
Specify an output file; remove fixed AVI format
[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 [output]"
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 [ -n "$1" ]; then
36    output="$1"
37    shift
38 else
39    output=output.avi
40 fi
41
42 if [ "$vcodec" = mpeg4-hq ]; then
43    vcodec=mpeg4
44    vopts="-mbd rd -flags +mv4+aic -trellis 2 -cmp 2 -subcmp 2"
45 fi
46
47 if [ "$pass" -eq 1 ]; then
48    exec ffmpeg $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -g 300 -bf 2 -c:a "$acodec" -b:a "$abitrate" $output_opts "$output"
49
50 elif [ "$pass" -eq 2 ]; then
51    ffmpeg -pass 1 $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -g 300 -bf 2 -an -f rawvideo -y /dev/null $output_opts &&
52    exec ffmpeg -pass 2 $input_opts -i "$input" -c:v "$vcodec" $vopts $vscale -b:v "$vbitrate" -g 300 -bf 2 -c:a "$acodec" -b:a "$abitrate" $output_opts "$output"
53
54 else
55    echo "Can only do 1 or 2 passes." >&2
56    exit 1
57 fi