Opened 6 years ago

Closed 4 years ago

Last modified 12 months ago

#7301 closed defect (invalid)

h264_nvenc / b_ref_mode each is not working

Reported by: smallishzulu Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords: nvenc
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description (last modified by Carl Eugen Hoyos)

Hi,

b_ref_mode each option is not working by saying out:
Each B frame as reference is not supported

GPU is: GeForce GTX 1080 (Pascal based)

Can there be a link or explanation given for supported cards ?

'udp://192.168.2.100:5000?pkt_size=188'
ffmpeg version N-91062-gf995aa8 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --prefix=/opt/ffmpeg --enable-nonfree --enable-gpl --extra-cflags='-I/opt/ffmpeg/include -I/usr/local/include -I/usr/local/cuda/include -I/opt/ndi/sdk/include' --extra-ldflags='-L/opt/ffmpeg/lib -L/usr/local/cuda/lib64 -L/opt/ndi/sdk/lib' --bindir=/opt/ffmpeg/bin --extra-libs=-ldl --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-nvenc --enable-libzvbi --enable-libfdk-aac --enable-libzimg --enable-libzmq --enable-libfreetype --enable-static --enable-shared --enable-hardcoded-tables --enable-vdpau --enable-cuda --enable-cuvid --enable-libvpx --enable-libmp3lame --enable-libndi_newtek --enable-openssl --enable-ffnvcodec --enable-libfontconfig --enable-libfribidi --enable-cuda-sdk --enable-libnpp
  libavutil      56. 18.102 / 56. 18.102
  libavcodec     58. 19.101 / 58. 19.101
  libavformat    58. 13.102 / 58. 13.102
  libavdevice    58.  4.100 / 58.  4.100
  libavfilter     7. 22.100 /  7. 22.100
  libswscale      5.  2.100 /  5.  2.100
  libswresample   3.  2.100 /  3.  2.100
  libpostproc    55.  2.100 / 55.  2.100
[h264 @ 0xd8c740] Reinit context to 1280x720, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/admintv/big-buck-bunny_294_1280x720.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: mp41
    creation_time   : 1970-01-01T00:00:00.000000Z
    title           : Big Buck Bunny
    encoder         : Lavf52.13.0
  Duration: 00:09:56.46, start: 0.000000, bitrate: 2353 kb/s
    Stream #0:0(und): Video: h264 (Constrained Baseline), 1 reference frame (avc1 / 0x31637661), yuv420p(left), 1280x720 [SAR 1:1 DAR 16:9], 2220 kb/s, 24 fps, 24 tbr, 24 tbn, 48 tbc (default)
    Metadata:
      creation_time   : 1970-01-01T00:00:00.000000Z
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
    Metadata:
      creation_time   : 1970-01-01T00:00:00.000000Z
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_nvenc))
  Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264 @ 0xdfa740] Reinit context to 1280x720, pix_fmt: yuv420p
[graph_1_in_0_1 @ 0x10f08c0] tb:1/48000 samplefmt:fltp samplerate:48000 chlayout:0x3
[graph 0 input from stream 0:0 @ 0x170fb80] w:1280 h:720 pixfmt:yuv420p tb:1/24 fr:24/1 sar:1/1 sws_param:flags=2
[scaler_out_0_0 @ 0x1710e80] w:720 h:576 flags:'bicubic' interl:0
[scaler_out_0_0 @ 0x1710e80] w:1280 h:720 fmt:yuv420p sar:1/1 -> w:720 h:576 fmt:yuv420p sar:64/45 flags:0x4
[h264_nvenc @ 0xdb3800] Loaded Nvenc version 8.1
[h264_nvenc @ 0xdb3800] Nvenc initialized successfully
[h264_nvenc @ 0xdb3800] 1 CUDA capable devices found
[h264_nvenc @ 0xdb3800] [ GPU #0 - < GeForce GTX 1080 > has Compute SM 6.1 ]
[h264_nvenc @ 0xdb3800] Each B frame as reference is not supported
[h264_nvenc @ 0xdb3800] No NVENC capable devices found
[h264_nvenc @ 0xdb3800] Nvenc unloaded
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
[aac @ 0xdb6200] Qavg: 188.848
[aac @ 0xdb6200] 2 frames left in the queue on closing
Conversion failed!

Change History (8)

comment:1 by Carl Eugen Hoyos, 6 years ago

Description: modified (diff)
Keywords: nvenc added

This ticket is missing a command line (Why don't you use 'ffmpeg -f lavfi -i testsrc2' and drop any unneeded options?) but why do you think this can be fixed in FFmpeg?

comment:2 by smallishzulu, 6 years ago

I am sorry. I lost the cmd line in copy & paste. Cmd line is:

/opt/ffmpeg/bin/ffmpeg -loglevel verbose -re -i /home/admintv/big-buck-bunny_294_1280x720.mp4 -aspect 16:9 -s 720x576 -map 0:0 -c:v:0 h264_nvenc -temporal-aq 1 -spatial-aq 1 -aq-strength 15 -2pass 1 -preset slow -cbr 1 -rc cbr -profile:v main -vb 1550k -minrate 1550k -maxrate 1550k -bufsize 1550k -muxrate 1790k -flags +ilme+ildct -top 1 -r 25 -pix_fmt yuv420p -map 0:1 -c:a:0 aac -b:a:0 128k -g 50 -f mpegts -bf 4 -refs 2 -b_ref_mode each 'udp://192.168.2.100:5000?pkt_size=188'

I will do your comment.

comment:3 by smallishzulu, 6 years ago

testsrc cmd line (simplified line):

/opt/ffmpeg/bin/ffmpeg -loglevel verbose -f lavfi -i testsrc2 -aspect 16:9 -s 720x576 -map 0:0 -c:v:0 h264_nvenc -preset slow -profile:v main -pix_fmt yuv420p -f mpegts -bf 4 -refs 2 -b_ref_mode each 'udp://192.168.2.100:5000?pkt_size=188'

ffmpeg version N-91062-gf995aa8 Copyright (c) 2000-2018 the FFmpeg developers

built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configuration: --prefix=/opt/ffmpeg --enable-nonfree --enable-gpl --extra-cflags='-I/opt/ffmpeg/include -I/usr/local/include -I/usr/local/cuda/include -I/opt/ndi/sdk/include' --extra-ldflags='-L/opt/ffmpeg/lib -L/usr/local/cuda/lib64 -L/opt/ndi/sdk/lib' --bindir=/opt/ffmpeg/bin --extra-libs=-ldl --enable-libx264 --enable-libx265 --enable-nonfree --enable-gpl --enable-nvenc --enable-libzvbi --enable-libfdk-aac --enable-libzimg --enable-libzmq --enable-libfreetype --enable-static --enable-shared --enable-hardcoded-tables --enable-vdpau --enable-cuda --enable-cuvid --enable-libvpx --enable-libmp3lame --enable-libndi_newtek --enable-openssl --enable-ffnvcodec --enable-libfontconfig --enable-libfribidi --enable-cuda-sdk --enable-libnpp
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 19.101 / 58. 19.101
libavformat 58. 13.102 / 58. 13.102
libavdevice 58. 4.100 / 58. 4.100
libavfilter 7. 22.100 / 7. 22.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100

[Parsed_testsrc2_0 @ 0xe80ec0] size:320x240 rate:25/1 duration:-1.000000 sar:1/1
Input #0, lavfi, from 'testsrc2':

Duration: N/A, start: 0.000000, bitrate: N/A

Stream #0:0: Video: rawvideo, 1 reference frame (I420 / 0x30323449), yuv420p, 320x240 [SAR 1:1 DAR 4:3], 25 tbr, 25 tbn, 25 tbc

Stream mapping:

Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))

Press [q] to stop, ? for help
[graph 0 input from stream 0:0 @ 0xeee840] w:320 h:240 pixfmt:yuv420p tb:1/25 fr:25/1 sar:1/1 sws_param:flags=2
[scaler_out_0_0 @ 0xeef5c0] w:720 h:576 flags:'bicubic' interl:0
[scaler_out_0_0 @ 0xeef5c0] w:320 h:240 fmt:yuv420p sar:1/1 -> w:720 h:576 fmt:yuv420p sar:16/15 flags:0x4
[h264_nvenc @ 0xebf480] Loaded Nvenc version 8.1
[h264_nvenc @ 0xebf480] Nvenc initialized successfully
[h264_nvenc @ 0xebf480] 1 CUDA capable devices found
[h264_nvenc @ 0xebf480] [ GPU #0 - < GeForce GTX 1080 > has Compute SM 6.1 ]
[h264_nvenc @ 0xebf480] Each B frame as reference is not supported
[h264_nvenc @ 0xebf480] No NVENC capable devices found
[h264_nvenc @ 0xebf480] Nvenc unloaded
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!


I think there should be an additional info to:
[h264_nvenc @ 0xdb3800] Each B frame as reference is not supported
[h264_nvenc @ 0xdb3800] No NVENC capable devices found

Like linking to a page for capable device. I even couldnt find a valuable info in SDK documents.

BTW, I use a Pascal series card and I thought it could be supported.
This can be a driver or an implementation issue as well.

As a side note, I have needed equipments to do NVIDIA GPU based tests if necessary.

comment:4 by smallishzulu, 6 years ago

Official NVIDIA Reply to this ticket over their ticket system:

Here's the description of the B-as-reference "each" mode, from the EncodeAPI header file:

NV_ENC_BFRAME_REF_MODE_EACH = 0x1, /< Each B-frame will be used for reference. currently not supported for H.264 */

As indicated, this mode is not supported at all, so the current behaviour is correct. When this mode becomes available in the future, the value returned on calling NvEncGetEncodeCaps() with the NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE capability will include NV_ENC_BFRAME_REF_MODE_EACH.

comment:5 by smallishzulu, 6 years ago

Resolution: invalid
Status: newclosed

in reply to:  4 comment:6 by Balling, 4 years ago

Resolution: invalid
Status: closedreopened

Replying to smallishzulu:

As indicated, this mode is not supported at all, so the current behaviour is correct. When this mode becomes available in the future, the value returned on calling NvEncGetEncodeCaps() with the NV_ENC_CAPS_SUPPORT_BFRAME_REF_MODE capability will include NV_ENC_BFRAME_REF_MODE_EACH.

This is not absolutely true because ret of nvenc_check_cap() we do not check correctly

(ret != 1 && ret != 3) 


https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/nvenc.c#L426

Last edited 4 years ago by Balling (previous) (diff)

comment:7 by Balling, 4 years ago

Resolution: invalid
Status: reopenedclosed
Note: See TracTickets for help on using tickets.