summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-02-05 04:15:37 +0100
committerJonas Smedegaard <dr@jones.dk>2021-02-05 06:01:00 +0100
commitddc5caba7a9d7df9bc9493494a82be6787433624 (patch)
tree09eff69b5b97351c924db5f188db7ee2f57a8f08 /localvideowebencode
parentbfbcb21d606cf181fa45b2b3a8604e9c30766505 (diff)
fix resolve bitrate, even for melt (by faking unsupported Constant Quality for vp8)
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode24
1 files changed, 13 insertions, 11 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 1073c53..6d3e917 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -470,13 +470,14 @@ encoder_vp8=libvpx
encoder_vp9=libvpx-vp9
encoder_h264=libx264
for vformat in vp8 vp9 h264; do
- eval "[ -n \"\$bitrate_$vformat\" ] || no_bitrate_$vformat=yes"
+ [ -z "$no_bitrate" ] || eval "no_bitrate_$vformat=yes"
+ eval "[ -n \"$no_bitrate\$no_bitrate_$vformat\" ] || do_bitrate_$vformat=yes"
eval "[ -z \"$no_q\$no_q_$vformat\" ] || q_$vformat="
[ -z "$q" ] || eval "q_$vformat=$q"
eval "[ -n \"\$q_$vformat\" ] || no_q_$vformat=yes"
- # melt supports dual-pass or Constant Quality modes only for h.264
- [ h264 = "$vformat" ] || [ -n "$vpxenc" ] || eval "[ -z \"$multipass\$q_$vformat\" ] || use_ffmpeg_$vformat=yes"
+ # melt supports dual-pass only for h.264
+ [ h264 = "$vformat" ] || [ -n "$vpxenc" ] || eval "[ -z \"$multipass\" ] || use_ffmpeg_$vformat=yes"
done
[ -n "$use_ffmpeg_h264" ] || use_melt_h264=yes
if [ -n "$use_ffmpeg_vp8$use_ffmpeg_vp9$use_vpxenc" ]; then
@@ -524,15 +525,16 @@ _ffmpeg_misc_vp9="-qmin $webm_qmin -qmax $webm_qmax -g 120 -deadline good -cpu-u
_vpxenc_misc_vp9="--min-q=$webm_qmin --max-q=$webm_qmax --kf-max-dist=120 --good --cpu-used=$cpu_vp9${profile_vp9:+ --profile=$profile_vp9} --tile-columns=$webm_tokenparts_log2 --tile-rows=$webm_tokenparts_log2 --auto-alt-ref=1 --lag-in-frames=$webm_lag --arnr-maxframes=7 --arnr-strength=5 --arnr-type=3"
# codec options
+# emulate VP8 Constant Quality using "loose" Constrained Quality
_melt_theora="vcodec=libtheora${bitrate_theora:+ vb=$bitrate_theora} qscale=$q_theora"
-_melt_vp8="vcodec=$encoder_vp8${pre_vp8:+ vpreset=$pre_vp8}${preset_vp8:+ preset=$preset_vp8}${bitrate_vp8:+ $_melt_bitrate_vp8}${q_vp8:+ $qkey_vp8=$q_vp8} $_melt_misc_vp8"
-_ffmpeg_vp8="-c:v $encoder_vp8${pre_vp8:+ -vpre $pre_vp8}${preset_vp8:+ preset $preset_vp8}${bitrate_vp8:+ $_ffmpeg_bitrate_vp8}${q_vp8:+ ${no_bitrate_vp8:+ -b:v 0 }-$qkey_vp8 $q_vp8} $_ffmpeg_misc_vp8"
-_vpxenc_vp8="--codec=vp8${bitrate_vp8:+ $_vpxenc_bitrate_vp8} --end-usage=${no_q_vp8:+vbr}${q_vp8:+cq --cq-level=$q_vp8} $_vpxenc_misc_vp8"
-_melt_vp9="vcodec=$encoder_vp9${pre_vp9:+ vpreset=$pre_vp9}${preset_vp9:+ preset=$preset_vp9}${bitrate_vp9:+ $_melt_bitrate_vp9}${q_vp9:+ $qkey_vp9=$q_vp9} $_melt_misc_vp9"
-_ffmpeg_vp9="-c:v $encoder_vp9${pre_vp9:+ -vpre $pre_vp9}${preset_vp9:+ -preset $preset_vp9}${bitrate_vp9:+ $_ffmpeg_bitrate_vp9}${q_vp9:+ ${no_bitrate_vp9:+-b:v 0 }-$qkey_vp9 $q_vp9} $_ffmpeg_misc_vp9"
-_vpxenc_vp9="--codec=vp9${bitrate_vp9:+ $_vpxenc_bitrate_vp9} --end-usage=${no_q_vp9:+vbr}${q_vp9:+cq --cq-level=$q_vp9} $_vpxenc_misc_vp8"
-_melt_h264="vcodec=$encoder_h264${preset_h264:+ vpreset=$preset_h264}${profile_h264:+ vprofile=$profile_h264}${x264tune:+ tune=$x264tune}${bitrate_h264:+ maxrate=$bitrate_h264 bufsize=$((bitrate_h264*2))}${q_h264:+ $qkey_h264=$q_h264} threads=0 movflags=+faststart"
-_ffmpeg_h264="-c:v $encoder_h264${preset_h264:+ -preset $preset_h264}${profile_h264:+ -profile:v $profile_h264}${x264tune:+ -tune $x264tune}${bitrate_h264:+ -maxrate $bitrate_h264 -bufsize $((bitrate_h264*2))}${q_h264:+ -$qkey_h264 $q_h264} -movflags +faststart"
+_melt_vp8="vcodec=$encoder_vp8${pre_vp8:+ vpreset=$pre_vp8}${preset_vp8:+ preset=$preset_vp8}${do_bitrate_vp8:+ $_melt_bitrate_vp8}${q_vp8:+ ${no_bitrate_vp8:+vb=$((bitrate_vp8*10)) }$qkey_vp8=$q_vp8} $_melt_misc_vp8"
+_ffmpeg_vp8="-c:v $encoder_vp8${pre_vp8:+ -vpre $pre_vp8}${preset_vp8:+ preset $preset_vp8}${do_bitrate_vp8:+ $_ffmpeg_bitrate_vp8}${q_vp8:+ ${no_bitrate_vp8:+-b:v $((bitrate_vp8*10)) }-$qkey_vp8 $q_vp8} $_ffmpeg_misc_vp8"
+_vpxenc_vp8="--codec=vp8${do_bitrate_vp8:+ $_vpxenc_bitrate_vp8} --end-usage=${no_q_vp8:+vbr}${q_vp8:+cq --cq-level=$q_vp8} $_vpxenc_misc_vp8"
+_melt_vp9="vcodec=$encoder_vp9${pre_vp9:+ vpreset=$pre_vp9}${preset_vp9:+ preset=$preset_vp9}${do_bitrate_vp9:+ $_melt_bitrate_vp9}${q_vp9:+ ${no_bitrate_vp9:+vb=0 }$qkey_vp9=$q_vp9} $_melt_misc_vp9"
+_ffmpeg_vp9="-c:v $encoder_vp9${pre_vp9:+ -vpre $pre_vp9}${preset_vp9:+ -preset $preset_vp9}${do_bitrate_vp9:+ $_ffmpeg_bitrate_vp9}${q_vp9:+ ${no_bitrate_vp9:+-b:v 0 }-$qkey_vp9 $q_vp9} $_ffmpeg_misc_vp9"
+_vpxenc_vp9="--codec=vp9${do_bitrate_vp9:+ $_vpxenc_bitrate_vp9} --end-usage=${no_q_vp9:+vbr}${q_vp9:+cq --cq-level=$q_vp9} $_vpxenc_misc_vp8"
+_melt_h264="vcodec=$encoder_h264${preset_h264:+ vpreset=$preset_h264}${profile_h264:+ vprofile=$profile_h264}${x264tune:+ tune=$x264tune}${do_bitrate_h264:+ maxrate=$bitrate_h264 bufsize=$((bitrate_h264*2))}${q_h264:+ $qkey_h264=$q_h264} threads=0 movflags=+faststart"
+_ffmpeg_h264="-c:v $encoder_h264${preset_h264:+ -preset $preset_h264}${profile_h264:+ -profile:v $profile_h264}${x264tune:+ -tune $x264tune}${do_bitrate_h264:+ -maxrate $bitrate_h264 -bufsize $((bitrate_h264*2))}${q_h264:+ -$qkey_h264 $q_h264} -movflags +faststart"
_melt_pcm="$_melt_downmix acodec=pcm_s16le"
_melt_vorbis="$_melt_downmix acodec=libvorbis aq=$quality_vorbis"
_ffmpeg_vorbis="$_ffmpeg_downmix -c:a libvorbis -aq $quality_vorbis"