move pstab to td-ps, improve td-gnuplot
[hband-tools.git] / half-baked / ffmpeg-x264-2pass.sh
bloba29f384cf23bbc4555e15896858860e558190b3a
1 #!/bin/bash
3 set -u
4 set -e
6 if [ $# -lt 4 ]
7 then
8 echo "$0 <input.avi> <video-bitrate> <audio-bitrate> <output.mp4> [<ffmpeg-options>]" >&2
9 exit 1
12 acodec=aac
13 #acodec=libvo_aacenc
15 input=$1
16 shift
17 vbr=${1}k
18 shift
19 abr=${1}
20 shift
21 out=$1
22 shift
24 declare opts=()
25 #opts=(-i "$input" -c:v libx264 -preset medium -b:v "$vbr" -c:a copy -f mp4)
26 #opts=(-i "$input" -c:v libx264 -preset medium -b:v "$vbr" -c:a $acodec -b:a "$abr" -f mp4)
27 opts+=(-i "$input" -c:v libx264 -preset medium -b:v "$vbr" -c:a $acodec)
28 if [ "${abr}" != '' ]; then opts+=(-b:a "$abr"k); fi
29 opts+=(-f mp4)
32 #FFMPEG=${FFMPEG:-ffmpeg3.2.4}
33 #FFMPEG=ffmpeg2.6
34 FFMPEG=ffmpeg
35 #FFMPEG="qemu-i386 /srv/bin/ffmpeg2.6"
37 $FFMPEG "${opts[@]}" -x264-params pass=1 "$@" -y /dev/null
39 $FFMPEG "${opts[@]}" -x264-params pass=2 "$@" "$out"