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

Submitted by elliottk on Aug. 14, 2019, 3:22 a.m.

Details

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

Commit Message

elliottk Aug. 14, 2019, 3:22 a.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 | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

James Zern Aug. 15, 2019, 12:35 a.m.
Hi,

On Tue, Aug 13, 2019 at 8:23 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 | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>

I think this is OK as it's similar to what is done for x264/5 [1].

> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 9b4fb3b4eb..a18d11c8aa 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -575,10 +575,10 @@ 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;
>

Can we take a library default here or does it default to bitrate and
have cq_level cleared?

>              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 28\n");
>

You may want to use the variable to produce the output in case it changes.

[1] https://bugs.chromium.org/p/aomedia/issues/detail?id=2219#c9
elliottk Aug. 15, 2019, 5:57 p.m.
On Wed, Aug 14, 2019 at 5:35 PM James Zern
<jzern-at-google.com@ffmpeg.org> wrote:
>
> Hi,
>
> On Tue, Aug 13, 2019 at 8:23 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 | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
>
> I think this is OK as it's similar to what is done for x264/5 [1].
>
> > diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> > index 9b4fb3b4eb..a18d11c8aa 100644
> > --- a/libavcodec/libaomenc.c
> > +++ b/libavcodec/libaomenc.c
> > @@ -575,10 +575,10 @@ 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;
> >
>
> Can we take a library default here or does it default to bitrate and
> have cq_level cleared?
I believe the library defaults to bitrate without a CQ level.
>
> >              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 28\n");
> >
>
> You may want to use the variable to produce the output in case it changes.
Good suggestion. I will update the patch.
>
> [1] https://bugs.chromium.org/p/aomedia/issues/detail?id=2219#c9
> _______________________________________________
> 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".

Patch hide | download patch | download mbox

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 9b4fb3b4eb..a18d11c8aa 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -575,10 +575,10 @@  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 28\n");
         }
     }
 
@@ -1091,7 +1091,7 @@  static const AVOption options[] = {
 };
 
 static const AVCodecDefault defaults[] = {
-    { "b",          "256*1000" },
+    { "b",                 "0" },
     { "qmin",             "-1" },
     { "qmax",             "-1" },
     { "g",                "-1" },