[FFmpeg-devel] Change libaom default to crf=28.

Submitted by elliottk on Aug. 15, 2019, 8:16 p.m.

Details

Message ID 20190815201620.203849-1-elliottk@google.com
State New
Headers show

Commit Message

elliottk Aug. 15, 2019, 8:16 p.m.
Current default is 256kbps, which produces inconsistent
results (too high for low-res, too low for hi-res).
Use CRF instead, which will adapt.
---
 libavcodec/libaomenc.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

James Zern Aug. 16, 2019, 5:51 p.m.
Hi,

On Thu, Aug 15, 2019 at 1:22 PM elliottk
<elliottk-at-google.com@ffmpeg.org> wrote:
>
> Current default is 256kbps, which produces inconsistent
> results (too high for low-res, too low for hi-res).
> Use CRF instead, which will adapt.
> ---
>  libavcodec/libaomenc.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 9b4fb3b4eb..621e897672 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -575,10 +575,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
>          if (enccfg.rc_end_usage == AOM_CQ) {
>              enccfg.rc_target_bitrate = 1000000;
>          } else {
> -            avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
> +            enccfg.rc_end_usage = AOM_Q;

Unless the docs are out of date this should be AOM_CQ level since crf
is mapped to that control [1].

> +            ctx->crf = 28;
>              av_log(avctx, AV_LOG_WARNING,
> -                   "Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n",
> -                   enccfg.rc_target_bitrate);
> +                   "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
> +                   ctx->crf);
>          }
>      }
>

[1] https://aomedia.googlesource.com/aom/+/refs/heads/master/aom/aomcx.h#221
"For this value to be used aom_codec_enc_cfg_t::rc_end_usage must be
set to #AOM_CQ."
elliottk Aug. 21, 2019, 12:31 a.m.
I believe the documentation is out of date. I added some debug
statements and verified that variable was being used to pull CRF
values when AOM_Q mode is set. I have
https://aomedia-review.googlesource.com/c/aom/+/94104 out to update
the documentation.


On Fri, Aug 16, 2019 at 10:59 AM James Zern
<jzern-at-google.com@ffmpeg.org> wrote:
>
> Hi,
>
> On Thu, Aug 15, 2019 at 1:22 PM elliottk
> <elliottk-at-google.com@ffmpeg.org> wrote:
> >
> > Current default is 256kbps, which produces inconsistent
> > results (too high for low-res, too low for hi-res).
> > Use CRF instead, which will adapt.
> > ---
> >  libavcodec/libaomenc.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> > index 9b4fb3b4eb..621e897672 100644
> > --- a/libavcodec/libaomenc.c
> > +++ b/libavcodec/libaomenc.c
> > @@ -575,10 +575,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
> >          if (enccfg.rc_end_usage == AOM_CQ) {
> >              enccfg.rc_target_bitrate = 1000000;
> >          } else {
> > -            avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
> > +            enccfg.rc_end_usage = AOM_Q;
>
> Unless the docs are out of date this should be AOM_CQ level since crf
> is mapped to that control [1].
>
> > +            ctx->crf = 28;
> >              av_log(avctx, AV_LOG_WARNING,
> > -                   "Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n",
> > -                   enccfg.rc_target_bitrate);
> > +                   "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
> > +                   ctx->crf);
> >          }
> >      }
> >
>
> [1] https://aomedia.googlesource.com/aom/+/refs/heads/master/aom/aomcx.h#221
> "For this value to be used aom_codec_enc_cfg_t::rc_end_usage must be
> set to #AOM_CQ."
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
elliottk Aug. 21, 2019, 7:16 p.m.
It appears that CRF=32 is a better default, since the scale is
different from other codecs. I will start a new thread.

On Tue, Aug 20, 2019 at 5:31 PM Elliott Karpilovsky <elliottk@google.com> wrote:
>
> I believe the documentation is out of date. I added some debug
> statements and verified that variable was being used to pull CRF
> values when AOM_Q mode is set. I have
> https://aomedia-review.googlesource.com/c/aom/+/94104 out to update
> the documentation.
>
>
> On Fri, Aug 16, 2019 at 10:59 AM James Zern
> <jzern-at-google.com@ffmpeg.org> wrote:
> >
> > Hi,
> >
> > On Thu, Aug 15, 2019 at 1:22 PM elliottk
> > <elliottk-at-google.com@ffmpeg.org> wrote:
> > >
> > > Current default is 256kbps, which produces inconsistent
> > > results (too high for low-res, too low for hi-res).
> > > Use CRF instead, which will adapt.
> > > ---
> > >  libavcodec/libaomenc.c | 9 +++++----
> > >  1 file changed, 5 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> > > index 9b4fb3b4eb..621e897672 100644
> > > --- a/libavcodec/libaomenc.c
> > > +++ b/libavcodec/libaomenc.c
> > > @@ -575,10 +575,11 @@ static av_cold int aom_init(AVCodecContext *avctx,
> > >          if (enccfg.rc_end_usage == AOM_CQ) {
> > >              enccfg.rc_target_bitrate = 1000000;
> > >          } else {
> > > -            avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
> > > +            enccfg.rc_end_usage = AOM_Q;
> >
> > Unless the docs are out of date this should be AOM_CQ level since crf
> > is mapped to that control [1].
> >
> > > +            ctx->crf = 28;
> > >              av_log(avctx, AV_LOG_WARNING,
> > > -                   "Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n",
> > > -                   enccfg.rc_target_bitrate);
> > > +                   "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
> > > +                   ctx->crf);
> > >          }
> > >      }
> > >
> >
> > [1] https://aomedia.googlesource.com/aom/+/refs/heads/master/aom/aomcx.h#221
> > "For this value to be used aom_codec_enc_cfg_t::rc_end_usage must be
> > set to #AOM_CQ."
> > _______________________________________________
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
James Zern Aug. 22, 2019, 1:01 a.m.
On Tue, Aug 20, 2019 at 5:31 PM Elliott Karpilovsky
<elliottk-at-google.com@ffmpeg.org> wrote:
>
> I believe the documentation is out of date. I added some debug
> statements and verified that variable was being used to pull CRF
> values when AOM_Q mode is set. I have
> https://aomedia-review.googlesource.com/c/aom/+/94104 out to update
> the documentation.
>

Thanks for making the update to the docs. Note that inline replies are
preferred to top-posting on this list.

Patch hide | download patch | download mbox

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 9b4fb3b4eb..621e897672 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -575,10 +575,11 @@  static av_cold int aom_init(AVCodecContext *avctx,
         if (enccfg.rc_end_usage == AOM_CQ) {
             enccfg.rc_target_bitrate = 1000000;
         } else {
-            avctx->bit_rate = enccfg.rc_target_bitrate * 1000;
+            enccfg.rc_end_usage = AOM_Q;
+            ctx->crf = 28;
             av_log(avctx, AV_LOG_WARNING,
-                   "Neither bitrate nor constrained quality specified, using default bitrate of %dkbit/sec\n",
-                   enccfg.rc_target_bitrate);
+                   "Neither bitrate nor constrained quality specified, using default CRF of %d\n",
+                   ctx->crf);
         }
     }
 
@@ -1091,7 +1092,7 @@  static const AVOption options[] = {
 };
 
 static const AVCodecDefault defaults[] = {
-    { "b",          "256*1000" },
+    { "b",                 "0" },
     { "qmin",             "-1" },
     { "qmax",             "-1" },
     { "g",                "-1" },