[FFmpeg-devel] [PATCH] avcodec/libsvtav1: Add support for multipass encoding

Oneric oneric at oneric.de
Mon Oct 31 00:20:51 EET 2022


On Sun, Oct 30, 2022 at 14:10:29 +0100, Lynne wrote:
> Sep 27, 2022, 23:06 by gustav.grusell at gmail.com:
> 
> > Implements support for 2-pass CRF and 3-pass VBR by implementing
> > reading and writing of stats file, and passing the pass number on
> > to the encoder. For 3-pass VBR, the first pass should be run with
> > '-pass 1', the second with '-pass 3' and the third with '-pass 2'.
> >
> > [...]
> 
> 2-pass doesn't seem to work, the encoder complains it's not the final pass.

fwiw, 2-pass CRF and 3-pass VBR work for me on a short sample with this
patch applied on top of 882a17068fd8e62c7d38c14e6fb160d7c9fc446a and using
SVT-AV1 1.3.0.

I'm not sure if 2-pass VBR is supposed to work, though I didn't look into
it too much. SVT-AV1 docs only mention 3-pass VBR[1] afaict and while
requesting output already in the second pass (`--pass 2` for SvtAv1EncApp
and `-pass 3` for patched ffmpeg) "works", the result misses the targeted
overall bitrate even more than singlepass VBR.

For reference here are the commands I used:

2-pass CRF:
-----------
  ./ffmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -crf 50 -g 300 -pass 1 -f null /dev/null \
  && ./ffmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -crf 50 -g 300 -pass 2 -f matroska crf_pass2.mkv


3-pass VBR:
-----------
  ./ffmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 1 \
    -f null /dev/null \
 && ./fmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 3 \
    -f null /dev/null \
 && ./fmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 2 \
    -f matroska vbr_pass2.mkv


"2-pass VBR" (probably bad idea):
---------------------------------
  ./ffmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 1 \
    -f null /dev/null \
  && ./fmpeg -i org.mkv -c:v libsvtav1 \
    -preset 4 -svtav1-params 'rc=1:tbr=500k' -g 300 -pass 3 \
    -f matroska vbr_pass2.mkv


[1]: https://gitlab.com/AOMediaCodec/SVT-AV1/-/blob/91b94efb2809e83d9bf041d8575b32f234dfef27/Docs/svt-av1_encoder_user_guide.md#multi-pass-vbr-1000-kbps-at-maximum-quality-from-24fps-yuv-1920x1080-input


More information about the ffmpeg-devel mailing list