summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2016-02-29 18:14:11 +0100
committerJonas Smedegaard <dr@jones.dk>2016-02-29 18:14:11 +0100
commit87b2c3acefb363f5e2d6e44a7219b2dce73a4c7b (patch)
treef53f8ed84c3deffd2900697dfcd215ff5a0a3629 /localvideowebencode
parentbc64b853a7f5bc04f1ee3752665e79bcbb52c7ce (diff)
Switch to ffmpeg.
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode126
1 files changed, 63 insertions, 63 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 3c5fc57..802882c 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-# Depends: libav-tools melt mediainfo
+# Depends: ffmpeg melt mediainfo
# Recommends: moreutils vpx-tools vorbis-tools opus-tools
#
# TODO:
@@ -185,17 +185,17 @@ stem=${stem:-$(basename "$infile_first" | perl -pe 's/\.[^.]*//')}
title=${title:-$stem}
# Avoid melt for VP8 and VP9: multipass broken for these codecs
-#use_avconv_vp8=yes
-#use_avconv_vp9=yes
+#use_ffmpeg_vp8=yes
+#use_ffmpeg_vp9=yes
use_vpxenc=yes
# Avoid discrete audio encoders if possible: may cause sync problems
#use_oggenc=yes
#use_opusenc=yes
-if [ -n "$use_avconv_vp8$use_avconv_vp9$use_vpxenc" ]; then
- [ -n "$use_oggenc" ] || use_avconv_ogg=yes
- [ -n "$use_opusenc" ] || use_avconv_opus=yes
+if [ -n "$use_ffmpeg_vp8$use_ffmpeg_vp9$use_vpxenc" ]; then
+ [ -n "$use_oggenc" ] || use_ffmpeg_ogg=yes
+ [ -n "$use_opusenc" ] || use_ffmpeg_opus=yes
[ -z "$use_oggenc$use_opusenc" ] || use_wav=yes
- [ -z "$use_avconv_ogg$use_avconv_opus" ] || use_matroska=yes
+ [ -z "$use_ffmpeg_ogg$use_ffmpeg_opus" ] || use_matroska=yes
fi
# Avoid AAC if possible: Lame arguably better than any free AAC encoder
# Argument for AAC: Safari possibly lacks mp3 support in video container
@@ -389,7 +389,7 @@ case "$audio" in
;;
*) exit1 "Unknown audio style \"$audio\".";;
esac
-channels=$(avprobe -v warning -show_streams "$infile_first" \
+channels=$(ffprobe -v warning -show_streams "$infile_first" \
| perl -ne 's/channels=// and print $_' || echo -1)
# adapt channel count and flags to reflect actual downmix/silence need
if [ -n "$stereo" ]; then
@@ -416,7 +416,7 @@ if [ -n "$stereo$mono" ]; then
# melt cannot downmix with (stereo?) filters applied (bug#763911)
if [ -n "$audioprefilters$compress$loudness$limit$filters" ]; then
if [ -z "${webm:+$use_oggenc}${webm_vp9:+$use_opusenc}" ]; then
- downmix_avconv=yes
+ downmix_ffmpeg=yes
else
downmix_oggenc=yes
downmix_oggenc=yes
@@ -428,8 +428,8 @@ fi
# generic options
melt="melt -progress"
-avconv="avconv -threads auto -y -v info -stats"
-avconv_chained="avconv -threads auto -y -v warning"
+ffmpeg="ffmpeg -threads auto -y -v info -stats"
+ffmpeg_chained="ffmpeg -threads auto -y -v warning"
vpxenc_chained="vpxenc --quiet ${processors:+-t $((processors-1))}"
oggenc="oggenc"
opusenc="opusenc"
@@ -437,9 +437,9 @@ _melt_infiles="${notsample:+$infiles}${sample:+$infile_first in=$((samplestart))
# filter options
_melt_video="progressive=1${framerate:+ frame_rate_num="$framerate_num" frame_rate_den="$framerate_den"}${size:+ s=${width:+$width}x${height:+$height}}${aspect:+ aspect=$aspect}"
-_avconv_video="${do_deinterlace:+-filter:v yadif}${framerate:+ -r $framerate_num/$framerate_den}${size:+ -s ${width:+$width}x${height:+$height}}${aspect:+ -aspect $aspect}"
+_ffmpeg_video="${do_deinterlace:+-filter:v yadif}${framerate:+ -r $framerate_num/$framerate_den}${size:+ -s ${width:+$width}x${height:+$height}}${aspect:+ -aspect $aspect}"
_melt_downmix="${downmix_melt:+ac=$channels}"
-_avconv_downmix="${downmix_avconv:+-ac $channels}"
+_ffmpeg_downmix="${downmix_ffmpeg:+-ac $channels}"
# FIXME: how to downmix to stereo?
_oggenc_downmix="${downmix_oggenc:+${mono:+--downmix}}"
_opusenc_downmix="${downmix_opusenc:+${stereo:+--downmix-stereo}${mono:+--downmix-mono}}"
@@ -449,46 +449,46 @@ _melt_postfilters_audio="${limit:+-filter ladspa.1077}"
# codec options
_melt_theora="vcodec=libtheora${bitrate:+ vb=$bitrate} qscale=$qscale_theora"
_melt_vp8="vcodec=libvpx vpreset=$sizepreset_vpx${bitrate_vp8:+ vb=$bitrate_vp8 minrate=$((bitrate_vp8/20)) maxrate=$((bitrate_vp8*12))} crf=$crf_vp8 cpu-used=$cpu_vp8"
-_avconv_vp8="-c:v libvpx -pre:v $sizepreset_vpx${bitrate_vp8:+ -b:v $bitrate_vp8 -minrate $((bitrate_vp8/20)) -maxrate $((bitrate_vp8*12))} -crf $crf_vp8 -cpu-used $cpu_vp8"
+_ffmpeg_vp8="-c:v libvpx -pre:v $sizepreset_vpx${bitrate_vp8:+ -b:v $bitrate_vp8 -minrate $((bitrate_vp8/20)) -maxrate $((bitrate_vp8*12))} -crf $crf_vp8 -cpu-used $cpu_vp8"
_vpxenc_vpx="--min-q=$webm_qmin --max-q=$webm_qmax${multipass:+ --minsection-pct=5 --maxsection-pct=1200} --kf-max-dist=120 --auto-alt-ref=1 --lag-in-frames=$webm_lag --arnr-maxframes=7 --arnr-strength=5 --arnr-type=3"
_vpxenc_vp8="--codec=vp8${bitrate_vp8:+ --target-bitrate=$((bitrate_vp8/1000))} --good --end-usage=${vbr_vp8:+vbr}${crf_vp8:+cq --cq-level=$crf_vp8} --cpu-used=$cpu_vp8 $_vpxenc_vpx --token-parts=$webm_tokenparts_log2"
_melt_vp9="vcodec=libvpx-vp9 vpreset=$sizepreset_vpx${bitrate_vp9:+ vb=$bitrate_vp9 minrate=$((bitrate_vp9/20)) maxrate=$((bitrate_vp9*12))} crf=$crf_vp9 cpu-used=$cpu_vp9"
-_avconv_vp9="-c:v libvpx-vp9 -pre:v $sizepreset_vpx${bitrate_vp9:+ -b:v $bitrate_vp9 -minrate $((bitrate_vp9/20)) -maxrate $((bitrate_vp9*12))} -crf $crf_vp9 -cpu-used $cpu_vp9"
+_ffmpeg_vp9="-c:v libvpx-vp9 -pre:v $sizepreset_vpx${bitrate_vp9:+ -b:v $bitrate_vp9 -minrate $((bitrate_vp9/20)) -maxrate $((bitrate_vp9*12))} -crf $crf_vp9 -cpu-used $cpu_vp9"
_vpxenc_vp9="--codec=vp9${bitrate_vp9:+ --target-bitrate=$((bitrate_vp9/1000))} --good --end-usage=${vbr_vp9:+vbr}${crf_vp9:+cq --cq-level=$crf_vp9} --cpu-used=$cpu_vp9 $_vpxenc_vpx --tile-columns=$webm_tokenparts_log2 --tile-rows=$webm_tokenparts_log2"
_melt_h264="vcodec=libx264 vpreset=$speedpreset_h264 vprofile=baseline${x264tune:+ tune=$x264tune} threads=0 movflags=+faststart crf=$crf_h264"
_melt_pcm="$_melt_downmix acodec=pcm_s16le"
_melt_vorbis="$_melt_downmix acodec=libvorbis aq=$quality_vorbis"
-_avconv_vorbis="$_avconv_downmix -c:a libvorbis -aq $quality_vorbis"
+_ffmpeg_vorbis="$_ffmpeg_downmix -c:a libvorbis -aq $quality_vorbis"
_oggenc_vorbis="$_oggenc_downmix -q $quality_vorbis"
_melt_opus="$_melt_downmix acodec=libopus ab=$((channels*bitrate_opus))k${opusapp:+ application=$opusapp}"
-_avconv_opus="$_avconv_downmix -c:a libopus -b:a $((channels*bitrate_opus))k${opusapp:+ -application $opusapp}"
+_ffmpeg_opus="$_ffmpeg_downmix -c:a libopus -b:a $((channels*bitrate_opus))k${opusapp:+ -application $opusapp}"
_opusenc_opus="$_opusenc_downmix --bitrate $((channels*bitrate_opus))"
_melt_mp3="$_melt_downmix acodec=libmp3lame aq=$quality_lame"
_melt_aac="$_melt_downmix acodec=aac ab=$((channels*bitrate_aac))k"
# container options
_melt_yuv4mpeg2="f=yuv4mpegpipe $_melt_video pix_fmt=yuv420p an=1 audio_off=1"
-_avconv_yuv4mpeg2_in="-f yuv4mpegpipe"
-_avconv_rawvideo="-f rawvideo"
+_ffmpeg_yuv4mpeg2_in="-f yuv4mpegpipe"
+_ffmpeg_rawvideo="-f rawvideo"
_melt_wav="f=wav $_melt_pcm vn=1 video_off=1"
-_avconv_wav_in="-f wav"
+_ffmpeg_wav_in="-f wav"
_oggenc_wav_in=
_opusenc_wav_in=
_melt_matroska_pcm="f=matroska $_melt_downmix $_melt_pcm vn=1 video_off=1"
-_avconv_matroska_pcm_in="-f matroska"
+_ffmpeg_matroska_pcm_in="-f matroska"
_melt_ogg="f=ogg $_melt_video $_melt_theora ${silence:+an=1 audio_off=1}${channels:+$_melt_vorbis}"
-_avconv_ogg_in="-f ogg"
-_avconv_ogg_vorbis="-f ogg -vn $_avconv_vorbis"
-_avconv_ogg_opus="-f ogg -vn $_avconv_opus"
+_ffmpeg_ogg_in="-f ogg"
+_ffmpeg_ogg_vorbis="-f ogg -vn $_ffmpeg_vorbis"
+_ffmpeg_ogg_opus="-f ogg -vn $_ffmpeg_opus"
_melt_webm="f=webm $_melt_video $_melt_vp8 ${silence:+an=1 audio_off=1}${channels:+$_melt_vorbis}"
-_avconv_webm="-f webm $_avconv_video $_avconv_vp8 ${silence:+-an}${channels:+ $_avconv_vorbis}"
-_avconv_webm_in="-f webm"
-_avconv_webm_onlyvideo="-f webm $_avconv_video $_avconv_vp8 -an}"
-_avconv_webm_keepvideo="-f webm $_avconv_video -c:v copy ${silence:+-an}${channels:+$_avconv_vorbis}"
-_avconv_webm_keepvideo_opus="-f webm $_avconv_video -c:v copy ${silence:+-an}${channels:+$_avconv_opus}"
+_ffmpeg_webm="-f webm $_ffmpeg_video $_ffmpeg_vp8 ${silence:+-an}${channels:+ $_ffmpeg_vorbis}"
+_ffmpeg_webm_in="-f webm"
+_ffmpeg_webm_onlyvideo="-f webm $_ffmpeg_video $_ffmpeg_vp8 -an}"
+_ffmpeg_webm_keepvideo="-f webm $_ffmpeg_video -c:v copy ${silence:+-an}${channels:+$_ffmpeg_vorbis}"
+_ffmpeg_webm_keepvideo_opus="-f webm $_ffmpeg_video -c:v copy ${silence:+-an}${channels:+$_ffmpeg_opus}"
_melt_webm_vp9="f=webm $_melt_video $_melt_vp9 ${silence:+an=1 audio_off=1}${channels:+$_melt_opus}"
-_avconv_webm_vp9="-f webm $_avconv_video $_avconv_vp9 ${silence:+-an}${channels:+$_avconv_opus}"
-_avconv_webm_onlyvideo_vp9="-f webm $_avconv_video $_avconv_vp9 -an}"
+_ffmpeg_webm_vp9="-f webm $_ffmpeg_video $_ffmpeg_vp9 ${silence:+-an}${channels:+$_ffmpeg_opus}"
+_ffmpeg_webm_onlyvideo_vp9="-f webm $_ffmpeg_video $_ffmpeg_vp9 -an}"
_melt_mp4="f=mp4 $_melt_video $_melt_h264 ${silence:+an=1 audio_off=1}${channels:+${use_mp3:+$_melt_mp3}${use_aac:+$_melt_aac}}"
_melt_img="f=image2 $_melt_video"
@@ -517,13 +517,13 @@ if [ -n "$multipass" ] && [ -n "$webm$vp9" ]; then
else
$melt $_melt_infiles $filters \
-consumer avformat:pipe:1 $_melt_yuv4mpeg2 \
- | $avconv_chained $_avconv_yuv4mpeg2_in -i pipe:0 \
- ${webm:+$_avconv_rawvideo $_avconv_vp8 -an \
+ | $ffmpeg_chained $_ffmpeg_yuv4mpeg2_in -i pipe:0 \
+ ${webm:+$_ffmpeg_rawvideo $_ffmpeg_vp8 -an \
-pass 1 -passlogfile ${stem}_vp8 /dev/null} \
- ${vp9:+$_avconv_rawvideo $_avconv_vp9 -an \
+ ${vp9:+$_ffmpeg_rawvideo $_ffmpeg_vp9 -an \
-pass 1 -passlogfile ${stem}_vp9 /dev/null}
- [ -z "$webm" ] || [ -n "$use_avconv_vp8" ] || mv -f ${stem}_vp8-*.log ${stem}_vp8_2pass.log
- [ -z "$vp9" ] || [ -n "$use_avconv_vp9" ] || mv -f ${stem}_vp9-*.log ${stem}_vp9_2pass.log
+ [ -z "$webm" ] || [ -n "$use_ffmpeg_vp8" ] || mv -f ${stem}_vp8-*.log ${stem}_vp8_2pass.log
+ [ -z "$vp9" ] || [ -n "$use_ffmpeg_vp9" ] || mv -f ${stem}_vp9-*.log ${stem}_vp9_2pass.log
fi
fi
@@ -542,18 +542,18 @@ if [ -n "$use_oggenc$use_opusenc$use_vpxenc" ] && [ -n "$webm$vp9" ]; then
$_melt_matroska_pcm}} \
-consumer avformat:pipe:1 $_melt_yuv4mpeg2 \
| pee \
- ${webm:+${use_avconv_vp8:+"$avconv_chained \
- $_avconv_yuv4mpeg2_in -i pipe:0 \
- $_avconv_webm_onlyvideo \
+ ${webm:+${use_ffmpeg_vp8:+"$ffmpeg_chained \
+ $_ffmpeg_yuv4mpeg2_in -i pipe:0 \
+ $_ffmpeg_webm_onlyvideo \
${multipass:+-pass 2 -passlogfile ${stem}_vp8} \
${stem}${channels:+_silent}.webm"}} \
${webm:+${use_vpxenc:+"$vpxenc_chained - $_vpxenc_vp8 \
${singlepass:+-p 1} \
${multipass:+-p 2 --pass=2 --fpf=${stem}_vp8.log} \
-o ${stem}${channels:+_silent}.webm"}} \
- ${vp9:+${use_avconv_vp9:+"$avconv_chained \
- $_avconv_yuv4mpeg2_in -i pipe:0 \
- $_avconv_webm_onlyvideo_vp9 \
+ ${vp9:+${use_ffmpeg_vp9:+"$ffmpeg_chained \
+ $_ffmpeg_yuv4mpeg2_in -i pipe:0 \
+ $_ffmpeg_webm_onlyvideo_vp9 \
${multipass:+-pass 2 -passlogfile ${stem}_vp9} \
${stem}_vp9${channels:+_silent}.webm"}} \
${vp9:+${use_vpxenc:+"$vpxenc_chained - $_vpxenc_vp9 \
@@ -564,31 +564,31 @@ if [ -n "$use_oggenc$use_opusenc$use_vpxenc" ] && [ -n "$webm$vp9" ]; then
echo "Encoding Vorbis audio and muxing with VP8 video..."
if [ -n "$use_oggenc" ]; then
$oggenc $_oggenc_wav_in $_oggenc_vorbis -o - $stem.wav \
- | $avconv_chained \
- $_avconv_webm_in -i ${stem}_silent.webm \
- $_avconv_ogg_in -i pipe:0 \
- $_avconv_webm_keepvideo $stem.webm
+ | $ffmpeg_chained \
+ $_ffmpeg_webm_in -i ${stem}_silent.webm \
+ $_ffmpeg_ogg_in -i pipe:0 \
+ $_ffmpeg_webm_keepvideo $stem.webm
else
- $avconv $_avconv_webm_in -i ${stem}_silent.webm \
- $_avconv_matroska_wav_in -i $stem.mkv \
- $_avconv_webm_keepvideo ${stem}.webm
+ $ffmpeg $_ffmpeg_webm_in -i ${stem}_silent.webm \
+ $_ffmpeg_matroska_wav_in -i $stem.mkv \
+ $_ffmpeg_webm_keepvideo ${stem}.webm
fi
fi
if [ -n "$vp9" ] && [ -n "$channels" ]; then
echo "Encoding Opus audio and muxing with WebM/VP9 video..."
if [ -n "$use_opusenc" ]; then
$opusenc $_opusenc_wav_in $_opusenc_opus -o - $stem.wav \
- | $avconv_chained \
- $_avconv_webm_in -i ${stem}_vp9_silent.webm \
- $_avconv_ogg_in -i pipe:0 \
- $_avconv_webm_keepvideo_opus ${stem}_vp9.webm
+ | $ffmpeg_chained \
+ $_ffmpeg_webm_in -i ${stem}_vp9_silent.webm \
+ $_ffmpeg_ogg_in -i pipe:0 \
+ $_ffmpeg_webm_keepvideo_opus ${stem}_vp9.webm
else
- $avconv $_avconv_webm_in -i ${stem}_vp9_silent.webm \
- $_avconv_matroska_wav_in -i $stem.mkv \
- $_avconv_webm_keepvideo_opus ${stem}_vp9.webm
+ $ffmpeg $_ffmpeg_webm_in -i ${stem}_vp9_silent.webm \
+ $_ffmpeg_matroska_wav_in -i $stem.mkv \
+ $_ffmpeg_webm_keepvideo_opus ${stem}_vp9.webm
fi
fi
-elif [ -n "$use_avconv_vp8$use_avconv_vp9" ] && [ -n "$webm$vp9" ]; then
+elif [ -n "$use_ffmpeg_vp8$use_ffmpeg_vp9" ] && [ -n "$webm$vp9" ]; then
echo "Encoding video..."
$melt $_melt_infiles \
${channels:+$audioprefilters \
@@ -600,14 +600,14 @@ elif [ -n "$use_avconv_vp8$use_avconv_vp9" ] && [ -n "$webm$vp9" ]; then
${channels:+-consumer avformat:$stem.wav $_melt_wav} \
-consumer avformat:pipe:1 $_melt_yuv4mpeg2 \
| pee \
- ${webm:+${use_avconv_vp8:+"$avconv_chained \
- $_avconv_yuv4mpeg2_in -i pipe:0 \
- $_avconv_webm \
+ ${webm:+${use_ffmpeg_vp8:+"$ffmpeg_chained \
+ $_ffmpeg_yuv4mpeg2_in -i pipe:0 \
+ $_ffmpeg_webm \
${multipass:+-pass 2 -passlogfile ${stem}_vp8} \
${stem}.webm"}} \
- ${vp9:+${use_avconv_vp9:+"$avconv_chained \
- $_avconv_yuv4mpeg2_in -i pipe:0 \
- $_avconv_webm_vp9 \
+ ${vp9:+${use_ffmpeg_vp9:+"$ffmpeg_chained \
+ $_ffmpeg_yuv4mpeg2_in -i pipe:0 \
+ $_ffmpeg_webm_vp9 \
${multipass:+-pass 2 -passlogfile ${stem}_vp9} \
${stem}_vp9.webm"}}
else