Number of reference frames

  • If, using NVENC, use or change the parameter "Number of reference frames", Voucoder crashes. The log contains the following:

    Code
    [15:57:10] Opening codec: h264_nvenc with options: 2pass=1|b=1550000|gpu=0|level=5.1|maxrate=8000000|preset=hq|profile=high|rc=vbr|refs=3
    [15:57:11] Failed opening codec: h264_nvenc
    [15:57:11] Unable to open video encoder: h264_nvenc
    [15:57:11] Closing encoders ...
    [15:57:11] Opening encoder failed! Aborting ...
    [15:57:11] 0000000025C765E0
  • NVidia gtx960.

    The same thing happens if you turn on "Weighted Prediction"

    Code
    16:13:59] Failed opening codec: h264_nvenc
    [16:13:59] Unable to open video encoder: h264_nvenc
    [16:13:59] Closing encoders ...
    [16:13:59] Opening encoder failed! Aborting ...
    [16:13:59] 0000000034B465E0
  • Vouk 4. Januar 2020 um 18:56

    Hat das Label Kein Bug hinzugefügt.
  • I just hit this problem and what's odd about it for me is that setting Ref frames "worked" fine prior to 2.3. I confirmed that setting ref frames in 2.2 between 1- 4 DID work and change the encoded stream accordingly. Now in 2.3+, it aborts the encoder process and drops back to the PPro window (not pretty). Note also that in 2.2, if I set Ref Frames = 8, I get a nice dialog message after encode starts that this value is not supported.

    BTW, analyzing the 2.3+ generated streams has a ref steams = 2.

  • Sigh. Here is a 2.2 log where it works. It's just that 2.2 logging is a bit more difficult to extract. This happens to be a 4K encode but good result for 1080p. My guess is that 2.3+ is doing something wrong on what parameter it is pushing out (not refs=4) so it's erroring.

    2pass=0 aq-strength=8 b=62000000 bf=2 bluray-compat=1 bufsize=60000000 g=30 gpu=0 init_qpB=51 init_qpI=51 init_qpP=51 level=5.1 maxrate=70000000 no-scenecut=0 nonref_p=1 preset=hq profile=high rc=vbr rc-lookahead=128 refs=4 spatial-aq=1 strict-gop=0 surfaces=16 temporal-aq=1

    Also the fact that 2.3+ crashes out vs. displaying some more user friendly error message would be great to fix. Note the user friendly error message when I set refs=8. Did that code get taken out?

  • BTW, I have been buried in other projects and haven't been able to track Voukoder development since probably May 2019. For the most part I've been using 1.2x and an even older nvenc_export version. This new set up is a work of art! Everything in my work flow is now on 4.x and it's working cleanly. The Ref frame issue is the only outstanding issue I have. (other than FFMpeg not supporting slices=4 for NVENC but that's a separate battle outside of what you have control over).

  • So the plot thickens. Running ffmpeg from the commandline on an OLD 2018 version of ffmpeg, it works fine (-refs=4). Using a new 4.2.2 build it now gets the error:

    [h264_nvenc @ 0000000002d49800] Multiple reference frames are not supported by the device

    [h264_nvenc @ 0000000002d49800] Provided device doesn't support required NVENC features

    Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters

    such as bit_rate, rate, width or height

    Conversion failed!

    So I found (thank you google) a bug report with ffmpeg https://trac.ffmpeg.org/ticket/8254 that explains what's going on:

    ------

    The -refs option used to be used to control the dpb size of nvenc.

    With the latest generation of cards and SDKs, nvidia added support for actually using multiple reference frames.

    That series of patches brings nvenc in line with libx264 in what the -refs option does.

    As of e929b2f248a9c49761475e07d1a089e05912d1c6, the old function of -refs has its own option, -dpb_size.

    Since -refs actually controlling the dpb size very likely was not what users of the option expected or intended, it was decided to go for this slightly breaking change.

    And it seems like it worked in making you aware of the -refs option not doing what you expected it do to.

    ------

    When I ran my command line with -dpb_size 4, it works (accepts dpb_size).

    >>> So now the next question is: What chipsets DO support the -refs option?

  • I used another NVenc tool that allowed me to dump capabilities of my card:

    #0: GeForce GTX 950 (768 cores, 1329 MHz)[PCIe3x16][442.74]

    List of available features.

    Codec: H.264/AVC

    Max Bframes 4

    B Ref Mode yes

    RC Modes 63

    Field Encoding yes

    MonoChrome no

    FMO no

    Quater-Pel MV yes

    B Direct Mode yes

    CABAC yes

    Adaptive Transform yes

    Max Temporal Layers 0

    Hierarchial P Frames no

    Hierarchial B Frames no

    Max Level 51

    Min Level 1

    4:4:4 yes

    Min Width 33

    Max Width 4096

    Min Height 17

    Max Height 4096

    Multiple Refs no

    So, it looks like my 950 has Ref Mode but NOT Multiple Refs. And this works in only one way:

    * leave Number of Reference frames undefined (should be able set it to 1 but even ffmpeg errors on that).

    * Set Use B frames as references = Middle

    Output now shows:

    FFmpeg: : Video: h264 (h264_nvenc) (High), 1 reference frame,

  • Yep, that's one take away, thanks :)

    also document that "B frames as References" = Middle is the only option with older cards.

    * Finally, a more graceful exit (actually non-exit) with a dialog message when the nvenc encode fails at startup would help.

    -- I'm adding a feature request for this.

  • Vouk 30. März 2020 um 11:28

    Hat das Label von Kein Bug auf In Bearbeitung geändert.
  • Vouk 30. März 2020 um 11:28

    Hat das Label von 3 auf 4 geändert.
  • Vouk 30. März 2020 um 11:28

    Hat das Label von Independent auf Adobe Premiere / MediaEncoder geändert.
  • Vouk 20. April 2020 um 18:32

    Hat das Label von In Bearbeitung auf Behoben geändert.