summaryrefslogtreecommitdiff
path: root/localvideowebencode
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2021-02-11 11:41:31 +0100
committerJonas Smedegaard <dr@jones.dk>2021-02-11 11:41:31 +0100
commit9c4b973cfedc75f30d5a3af68b036c64621b04af (patch)
tree5f63b0f9988ca3201df94d3ae0e9e510a145edfe /localvideowebencode
parent43139560b87a29ca575384432a02a7336bac61b8 (diff)
use Bjornsgaard Metric as cross-codec factor
Diffstat (limited to 'localvideowebencode')
-rwxr-xr-xlocalvideowebencode35
1 files changed, 19 insertions, 16 deletions
diff --git a/localvideowebencode b/localvideowebencode
index 8bccd0b..86a753c 100755
--- a/localvideowebencode
+++ b/localvideowebencode
@@ -209,38 +209,41 @@ compression=normal
# currently used: VMAF 93 of x264 for 360p30 (equiv. crf 23 at medium)
# 2) pick reference codec (incl. normal settings)
# 3) render reference frame format with --compression=quality
-# * check that bpp is near "refbpp" of 0.12
-# (otherwise adapt settings or do research and update refbpp)
+# * establish "Bits Per Pixel" and define as refbpp
+# currently used: 0.12 (TODO: seems too high - ancient reference)
# 4) render misc. frame formats (esp. modulus 16) with --compression=quality
-# * check that bpp derives from refbpp by "rule of .75"
-# (otherwise adapt settings and/or do research and update rule)
+# * establish and define curve formula
+# currently used: "rule of .75" (TODO: seems slightly too high)
# 5) render misc. frame formats with --compression=normal
-# * check that bpp derives from refbpp by "rule of .75"
+# * verify that bpp derives from refbpp as expected
# 6) optionally pick dirty/hq settings
# * check that --compression=quality has filesize similar as normal
# establish/verify rendering settings for non-reference codec
#
# 1) pick normal settings
-# 2) render reference frame format with --compression=quality
-# * check that this "codec-bpp" deviates reasonably from refbpp
+# 2) render reference frame format with --compression=quality at misc --quality
+# * establish quality similar to reference encoding, and define as q
# 3) render misc. frame formats (esp. modulus 16) with --compression=quality
-# * check that bpp derives from codec-bpp by "rule of .75"
-# (otherwise adapt settings and/or extend rule)
+# * establish the "Bjontegaard" bitrate distance, and define as b_dbr
+# <https://streaminglearningcenter.com/encoding/compute-bd-rate-functions.html>
+# * establish and define bpp curve
# 4) render misc. frame formats with --compression=normal
-# * check that bpp derives from codec-bpp by "rule of .75"
+# * verify that content quality is comparable to reference encoding
+# * verify that bpp derives from refbpp as expected
# 5) optionally pick dirty/hq settings
# * check that --compression=quality has similar filesize as normal
# Theora seems to compress ~100% worse than H.264
# (reportedly 76% worse in 2010, and libtheora has not improved since)
# <http://compression.ru/video/codec_comparison/h264_2010/>
-factor_theora=200/100
+b_dbr_theora=100
# VP8 is rumored to compress ~20% worse than H.264
-factor_vp8=120/100
+b_dbr_vp8=20
# VP9 compresses ~30% better than H.264 for practical use-cases
# <https://engineering.fb.com/2018/04/10/video-engineering/av1-beats-x264-and-libvpx-vp9-in-practical-use-case/>
-factor_vp9=70/100
+b_dbr_vp9=-30
+
# Mimic ReplayGain level when loudness is enabled (EBU R128: -23LUFS)
# <https://auphonic.com/blog/2013/01/07/loudness-targets-mobile-audio-podcasts-radio-tv/>
lufs=-18
@@ -541,9 +544,9 @@ fi
if [ -n "$_pixels" ] && [ -n "$_frames" ]; then
bitrate_avc=$(perl -E '$refsize=640*360;' \
-E "say int( +(($_pixels/\$refsize)**0.75*\$refsize*$_frames*$refbpp) )")
- bitrate_theora=$(perl -E "say int( +($bitrate_avc*$factor_theora) )") #"
- bitrate_vp8=$(perl -E "say int( +($bitrate_avc*$factor_vp8) )") #"
- bitrate_vp9=$(perl -E "say int( +($bitrate_avc*$factor_vp9) )") #"
+ bitrate_theora=$(perl -E "say int( +($bitrate_avc*(100+($b_dbr_theora))/100) )") #"
+ bitrate_vp8=$(perl -E "say int( +($bitrate_avc*(100+($b_dbr_vp8))/100) )") #"
+ bitrate_vp9=$(perl -E "say int( +($bitrate_avc*(100+($b_dbr_vp9))/100) )") #"
fi
# default per-codec-channel bitrates