Number of reference frames

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

    [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"

    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
  • Can you test this with ffmpeg.exe on the command line? OR run premiere from within windbg.exe and check the low level log file there?

    I am not 100% sure but maybe your GPU does not support these options.

  • Vouk

    Added the Label Not a bug
  • Vouk

    Added the Label 3
  • Vouk

    Set the Label from Adobe Premiere / MediaEncoder to Independent
  • 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.

  • The NVIDIA driver reports:

    [15:14:07] FFmpeg: Multiple reference frames are not supported by the device

    The one working export in the logfile was using libx264 which doesn't have this limitation.

  • 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 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

    Set the Label from Not a bug to In Progress
  • Vouk

    Set the Label from 3 to 4
  • Vouk

    Set the Label from In Progress to Fixed