#8254: ffmpeg encoding with nvenc broken by a commit
-------------------------------------+-------------------------------------
             Reporter:  hydra3333    |                    Owner:
                 Type:  defect       |                   Status:  new
             Priority:  important    |                Component:
                                     |  undetermined
              Version:  git-master   |               Resolution:
             Keywords:  regression   |               Blocked By:
             Blocking:               |  Reproduced by developer:  0
Analyzed by developer:  0            |
-------------------------------------+-------------------------------------

Comment (by hydra3333):

 OK, it "breaks" on commit 567b5e33d9d77919ee920c091f4273c5b38fc821
 "avcodec/nvenc: add multiple reference frames support"
 Likely in here
 {{{
 +#ifdef NVENC_HAVE_MULTIPLE_REF_FRAMES
 +    ret = nvenc_check_cap(avctx,
 NV_ENC_CAPS_SUPPORT_MULTIPLE_REF_FRAMES);
 +    if(avctx->refs != NV_ENC_NUM_REF_FRAMES_AUTOSELECT && ret <= 0) {
 +        av_log(avctx, AV_LOG_VERBOSE, "Multiple reference frames are not
 supported\n");
 +        return AVERROR(ENOSYS);
 +    }
 +#else
 +    if(avctx->refs != 0) {
 +        av_log(avctx, AV_LOG_VERBOSE, "Multiple reference frames need SDK
 9.1 at build time\n");
 +        return AVERROR(ENOSYS);
 +    }
 +#endif
 }}}


 On The Other Hand, if "-refs 3" is omitted from the commandline, it works
 on the 1050Ti.

 The nvidia support matrix https://developer.nvidia.com/video-encode-
 decode-gpu-support-matrix doesn't seem to mention refs.

 It seems possible that prior to this commit, "-refs 3" was ignored or
 perhaps defaulted to 0 ?

 In which case, maybe it's not a bug, just that the 1050Ti nvenc encoder is
 (was always invisibly?) not capable of it and ffmpeg just behaved
 differently before this commit.

 Perhaps some form of expanded error message may help ffmpeg users who
 newly encounter this error message when "it used to work".
 Say, something like
 "Multiple reference frames for nvenc are not supported on this model of
 nvidia hardware graphics card"

 Logs for this commit :

 {{{
 
--------------------------------------------------------------------------------------------------------------
 "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -nostats -v verbose
 -init_hw_device opencl=ocl:0.0 -filter_hw_device ocl -i
 "D:\temp\SCRATCH\demo1.mpg" -map_metadata -1 -sws_flags
 lanczos+accurate_rnd+full_chroma_int+full_chroma_inp -filter_complex
 
"[0:v]yadif=0:0:0,hwupload,unsharp_opencl=lx=3:ly=3:la=0.5:cx=3:cy=3:ca=0.5,hwdownload,format=pix_fmts=yuv420p,setdar=dar=16/9"
 -c:v h264_nvenc -pix_fmt nv12 -preset slow -bf 2 -g 50 -refs 3 -rc:v
 vbr_hq -rc-lookahead:v 32 -cq 22 -qmin 16 -qmax 25 -coder cabac -strict
 experimental -movflags +faststart+write_colr -profile:v high -level 5.1
 -af
 
loudnorm=I=-16:TP=0.0:LRA=11:measured_I=-24.17:measured_LRA=7.30:measured_TP=-5.13:measured_thresh=-34.87:offset=-0.19:linear=true:print_format=summary
 -c:a libfdk_aac -cutoff 18000 -ab 384k -ar 48000  -y "T:\HDTV\autoTVS-
 mpg\Converted\demo1.aac.mp4"
 ffmpeg version
 N-95125-g567b5e33d9-hydra3333/h3333_python_cross_compile_script_v02_courtesy
 Copyright (c) 2000-2019 the FFmpeg developers
   built with gcc 9.2.0 (GCC)
   configuration: --arch=x86_64 --target-os=mingw32 --cross-
 prefix=x86_64-w64-mingw32- --pkg-config=pkg-config --disable-w32threads
 --enable-pthreads --enable-cross-compile --enable-pic --enable-libsoxr
 --enable-libass --enable-iconv --enable-libtwolame --enable-libzvbi
 --enable-libcaca --enable-libmodplug --enable-cuvid --enable-libmp3lame
 --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis
 --enable-libtheora --enable-libspeex --enable-libgsm --enable-libopus
 --enable-bzlib --enable-libopencore-amrnb --enable-libopencore-amrwb
 --enable-libvo-amrwbenc --enable-libvpx --enable-libilbc --enable-
 libwavpack --enable-libwebp --enable-dxva2 --disable-avisynth --enable-
 vapoursynth --enable-gray --enable-libmysofa --enable-libflite --enable-
 lzma --enable-libsnappy --enable-libzimg --enable-libx264 --enable-libx265
 --enable-libaom --enable-libdav1d --enable-frei0r --enable-filter=frei0r
 --enable-librubberband --enable-libvidstab --enable-libxvid --enable-
 libgme --enable-runtime-cpudetect --enable-libfribidi --enable-gnutls
 --enable-gmp --enable-fontconfig --enable-libfontconfig --enable-
 libfreetype --enable-libbluray --enable-libcdio --disable-schannel
 --enable-ladspa --enable-libxml2 --enable-libdavs2 --enable-libopenmpt
 --enable-libxavs --enable-libxavs2 --enable-libsrt --enable-libmfx
 --enable-amf --enable-ffnvcodec --enable-cuvid --enable-opengl --enable-
 d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-gpl --extra-
 version='hydra3333/h3333_python_cross_compile_script_v02_courtesy
 _of_DeadSix27/python_cross_compile_script' --enable-avresample --pkg-
 config-flags=--static --extra-libs='-lpsapi -lintl -liconv' --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --enable-
 libbluray
 
--prefix=/home/u/Desktop/workdir/x86_64_products/ffmpeg_static_non_free_opencl.installed
 --disable-shared --enable-static --enable-cuda-nvcc --enable-nonfree
 --enable-opencl --enable-nonfree --enable-libfdk-aac --enable-decklink
 --extra-cflags=-DLIBXML_STATIC --extra-cflags=-DGLIB_STATIC_COMPILATION
   libavutil      56. 35.100 / 56. 35.100
   libavcodec     58. 59.101 / 58. 59.101
   libavformat    58. 33.100 / 58. 33.100
   libavdevice    58.  9.100 / 58.  9.100
   libavfilter     7. 59.100 /  7. 59.100
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
 Routing option strict to both codec and muxer layer
 [AVHWDeviceContext @ 0000025e5163d500] 0.0: NVIDIA CUDA / GeForce GTX 1050
 Ti
 [AVHWDeviceContext @ 0000025e5163d500] DXVA2 to OpenCL mapping function
 found (clCreateFromDX9MediaSurfaceKHR).
 [AVHWDeviceContext @ 0000025e5163d500] DXVA2 in OpenCL acquire function
 found (clEnqueueAcquireDX9MediaSurfacesKHR).
 [AVHWDeviceContext @ 0000025e5163d500] DXVA2 in OpenCL release function
 found (clEnqueueReleaseDX9MediaSurfacesKHR).
 [AVHWDeviceContext @ 0000025e5163d500] The cl_khr_d3d11_sharing extension
 is required for D3D11 to OpenCL mapping.
 [AVHWDeviceContext @ 0000025e5163d500] D3D11 to OpenCL mapping not usable.
 [mpeg @ 0000025e51641b80] max_analyze_duration 5000000 reached at 5000000
 microseconds st:0
 Input #0, mpeg, from 'D:\temp\SCRATCH\demo1.mpg':
   Duration: 00:44:49.53, start: 0.228244, bitrate: 3781 kb/s
     Stream #0:0[0x1e0]: Video: mpeg2video (Main), 1 reference frame,
 yuv420p(tv, bt470bg, top first, left), 720x576 [SAR 64:45 DAR 16:9], 25
 fps, 25 tbr, 90k tbn, 50 tbc
     Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 256 kb/s
 Stream mapping:
   Stream #0:0 (mpeg2video) -> yadif (graph 0)
   setdar (graph 0) -> Stream #0:0 (h264_nvenc)
   Stream #0:1 -> #0:1 (mp2 (native) -> aac (libfdk_aac))
 Press [q] to stop, [?] for help
 [graph 0 input from stream 0:0 @ 0000025e5ede6e00] w:720 h:576
 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:64/45 sws_param:flags=2
 [auto_scaler_0 @ 0000025e5ede8b00] w:iw h:ih flags:'bilinear' interl:0
 [format @ 0000025e5ede8300] auto-inserting filter 'auto_scaler_0' between
 the filter 'Parsed_setdar_5' and the filter 'format'
 [Parsed_setdar_5 @ 0000025e5ede8000] w:720 h:576 dar:16/9 sar:64/45 ->
 dar:16/9 sar:64/45
 [auto_scaler_0 @ 0000025e5ede8b00] w:720 h:576 fmt:yuv420p sar:64/45 ->
 w:720 h:576 fmt:nv12 sar:64/45 flags:0x2
 [h264_nvenc @ 0000025e51695b00] Loaded Nvenc version 9.1
 [h264_nvenc @ 0000025e51695b00] Nvenc initialized successfully
 [h264_nvenc @ 0000025e51695b00] 1 CUDA capable devices found
 [h264_nvenc @ 0000025e51695b00] [ GPU #0 - < GeForce GTX 1050 Ti > has
 Compute SM 6.1 ]
 [h264_nvenc @ 0000025e51695b00] Multiple reference frames are not
 supported
 [h264_nvenc @ 0000025e51695b00] No NVENC capable devices found
 [h264_nvenc @ 0000025e51695b00] 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
 [AVIOContext @ 0000025e51697580] Statistics: 0 seeks, 0 writeouts
 [AVIOContext @ 0000025e5164b440] Statistics: 2642064 bytes read, 2 seeks
 Conversion failed!
 
--------------------------------------------------------------------------------------------------------------
 # same commandline without -refs 3
 "C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -nostats -v verbose
 -init_hw_device opencl=ocl:0.0 -filter_hw_device ocl -i
 "D:\temp\SCRATCH\demo1.mpg" -map_metadata -1 -sws_flags
 lanczos+accurate_rnd+full_chroma_int+full_chroma_inp -filter_complex
 
"[0:v]yadif=0:0:0,hwupload,unsharp_opencl=lx=3:ly=3:la=0.5:cx=3:cy=3:ca=0.5,hwdownload,format=pix_fmts=yuv420p,setdar=dar=16/9"
 -c:v h264_nvenc -pix_fmt nv12 -preset slow -bf 2 -g 50 -rc:v vbr_hq -rc-
 lookahead:v 32 -cq 22 -qmin 16 -qmax 25 -coder cabac -strict experimental
 -movflags +faststart+write_colr -profile:v high -level 5.1 -af
 
loudnorm=I=-16:TP=0.0:LRA=11:measured_I=-24.17:measured_LRA=7.30:measured_TP=-5.13:measured_thresh=-34.87:offset=-0.19:linear=true:print_format=summary
 -c:a libfdk_aac -cutoff 18000 -ab 384k -ar 48000  -y "T:\HDTV\autoTVS-
 mpg\Converted\demo1.aac.mp4"
 ffmpeg version
 N-95125-g567b5e33d9-hydra3333/h3333_python_cross_compile_script_v02_courtesy
 Copyright (c) 2000-2019 the FFmpeg developers
   built with gcc 9.2.0 (GCC)
   configuration: --arch=x86_64 --target-os=mingw32 --cross-
 prefix=x86_64-w64-mingw32- --pkg-config=pkg-config --disable-w32threads
 --enable-pthreads --enable-cross-compile --enable-pic --enable-libsoxr
 --enable-libass --enable-iconv --enable-libtwolame --enable-libzvbi
 --enable-libcaca --enable-libmodplug --enable-cuvid --enable-libmp3lame
 --enable-version3 --enable-zlib --enable-librtmp --enable-libvorbis
 --enable-libtheora --enable-libspeex --enable-libgsm --enable-libopus
 --enable-bzlib --enable-libopencore-amrnb --enable-libopencore-amrwb
 --enable-libvo-amrwbenc --enable-libvpx --enable-libilbc --enable-
 libwavpack --enable-libwebp --enable-dxva2 --disable-avisynth --enable-
 vapoursynth --enable-gray --enable-libmysofa --enable-libflite --enable-
 lzma --enable-libsnappy --enable-libzimg --enable-libx264 --enable-libx265
 --enable-libaom --enable-libdav1d --enable-frei0r --enable-filter=frei0r
 --enable-librubberband --enable-libvidstab --enable-libxvid --enable-
 libgme --enable-runtime-cpudetect --enable-libfribidi --enable-gnutls
 --enable-gmp --enable-fontconfig --enable-libfontconfig --enable-
 libfreetype --enable-libbluray --enable-libcdio --disable-schannel
 --enable-ladspa --enable-libxml2 --enable-libdavs2 --enable-libopenmpt
 --enable-libxavs --enable-libxavs2 --enable-libsrt --enable-libmfx
 --enable-amf --enable-ffnvcodec --enable-cuvid --enable-opengl --enable-
 d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-gpl --extra-
 version='hydra3333/h3333_python_cross_compile_script_v02_courtesy
 _of_DeadSix27/python_cross_compile_script' --enable-avresample --pkg-
 config-flags=--static --extra-libs='-lpsapi -lintl -liconv' --extra-
 cflags=-DLIBTWOLAME_STATIC --extra-cflags=-DMODPLUG_STATIC --enable-
 libbluray
 
--prefix=/home/u/Desktop/workdir/x86_64_products/ffmpeg_static_non_free_opencl.installed
 --disable-shared --enable-static --enable-cuda-nvcc --enable-nonfree
 --enable-opencl --enable-nonfree --enable-libfdk-aac --enable-decklink
 --extra-cflags=-DLIBXML_STATIC --extra-cflags=-DGLIB_STATIC_COMPILATION
   libavutil      56. 35.100 / 56. 35.100
   libavcodec     58. 59.101 / 58. 59.101
   libavformat    58. 33.100 / 58. 33.100
   libavdevice    58.  9.100 / 58.  9.100
   libavfilter     7. 59.100 /  7. 59.100
   libavresample   4.  0.  0 /  4.  0.  0
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
 Routing option strict to both codec and muxer layer
 [AVHWDeviceContext @ 0000023cd92cd480] 0.0: NVIDIA CUDA / GeForce GTX 1050
 Ti
 [AVHWDeviceContext @ 0000023cd92cd480] DXVA2 to OpenCL mapping function
 found (clCreateFromDX9MediaSurfaceKHR).
 [AVHWDeviceContext @ 0000023cd92cd480] DXVA2 in OpenCL acquire function
 found (clEnqueueAcquireDX9MediaSurfacesKHR).
 [AVHWDeviceContext @ 0000023cd92cd480] DXVA2 in OpenCL release function
 found (clEnqueueReleaseDX9MediaSurfacesKHR).
 [AVHWDeviceContext @ 0000023cd92cd480] The cl_khr_d3d11_sharing extension
 is required for D3D11 to OpenCL mapping.
 [AVHWDeviceContext @ 0000023cd92cd480] D3D11 to OpenCL mapping not usable.
 [mpeg @ 0000023cd92d1ac0] max_analyze_duration 5000000 reached at 5000000
 microseconds st:0
 Input #0, mpeg, from 'D:\temp\SCRATCH\demo1.mpg':
   Duration: 00:44:49.53, start: 0.228244, bitrate: 3781 kb/s
     Stream #0:0[0x1e0]: Video: mpeg2video (Main), 1 reference frame,
 yuv420p(tv, bt470bg, top first, left), 720x576 [SAR 64:45 DAR 16:9], 25
 fps, 25 tbr, 90k tbn, 50 tbc
     Stream #0:1[0x1c0]: Audio: mp2, 48000 Hz, stereo, s16p, 256 kb/s
 Stream mapping:
   Stream #0:0 (mpeg2video) -> yadif (graph 0)
   setdar (graph 0) -> Stream #0:0 (h264_nvenc)
   Stream #0:1 -> #0:1 (mp2 (native) -> aac (libfdk_aac))
 Press [q] to stop, [?] for help
 [graph 0 input from stream 0:0 @ 0000023cd92d4280] w:720 h:576
 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:64/45 sws_param:flags=2
 [auto_scaler_0 @ 0000023cd92d4480] w:iw h:ih flags:'bilinear' interl:0
 [format @ 0000023cd92d3880] auto-inserting filter 'auto_scaler_0' between
 the filter 'Parsed_setdar_5' and the filter 'format'
 [Parsed_setdar_5 @ 0000023cd92d3e80] w:720 h:576 dar:16/9 sar:64/45 ->
 dar:16/9 sar:64/45
 [auto_scaler_0 @ 0000023cd92d4480] w:720 h:576 fmt:yuv420p sar:64/45 ->
 w:720 h:576 fmt:nv12 sar:64/45 flags:0x2
 [h264_nvenc @ 0000023cd9326a80] Loaded Nvenc version 9.1
 [h264_nvenc @ 0000023cd9326a80] Nvenc initialized successfully
 [h264_nvenc @ 0000023cd9326a80] 1 CUDA capable devices found
 [h264_nvenc @ 0000023cd9326a80] [ GPU #0 - < GeForce GTX 1050 Ti > has
 Compute SM 6.1 ]
 [h264_nvenc @ 0000023cd9326a80] supports NVENC
 [h264_nvenc @ 0000023cd9326a80] Lookahead enabled: depth 32, scenecut
 enabled, B-adapt enabled.
 [graph_1_in_0_1 @ 0000023cd92d3f80] tb:1/48000 samplefmt:s16p
 samplerate:48000 chlayout:0x3
 [Parsed_loudnorm_0 @ 0000023cd92d3680] auto-inserting filter
 'auto_resampler_0' between the filter 'graph_1_in_0_1' and the filter
 'Parsed_loudnorm_0'
 [format_out_0_1 @ 0000023cd92d3980] auto-inserting filter
 'auto_resampler_1' between the filter 'Parsed_loudnorm_0' and the filter
 'format_out_0_1'
 [auto_resampler_0 @ 0000023cd92d4080] ch:2 chl:stereo fmt:s16p r:48000Hz
 -> ch:2 chl:stereo fmt:dbl r:192000Hz
 [auto_resampler_1 @ 0000023ce67e7340] ch:2 chl:stereo fmt:dbl r:192000Hz
 -> ch:2 chl:stereo fmt:s16 r:48000Hz
 Output #0, mp4, to 'T:\HDTV\autoTVS-mpg\Converted\demo1.aac.mp4':
   Metadata:
     encoder         : Lavf58.33.100
     Stream #0:0: Video: h264 (h264_nvenc) (High), 1 reference frame (avc1
 / 0x31637661), nv12(left), 720x576 [SAR 64:45 DAR 16:9], q=16-25, 2000
 kb/s, 25 fps, 12800 tbn, 25 tbc
     Metadata:
       encoder         : Lavc58.59.101 h264_nvenc
     Side data:
       cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000
 vbv_delay: N/A
     Stream #0:1: Audio: aac (libfdk_aac) (mp4a / 0x6134706D), 48000 Hz,
 stereo, s16, delay 2048, 384 kb/s
     Metadata:
       encoder         : Lavc58.59.101 libfdk_aac
 [mpeg2video @ 0000023ce682b2c0] ac-tex damaged at 28 27
 [mpeg2video @ 0000023ce682b2c0] Warning MVs not available
 [mpeg2video @ 0000023ce682b2c0] concealing 90 DC, 90 AC, 90 MV errors in B
 frame
 D:\temp\SCRATCH\demo1.mpg: corrupt decoded frame in stream 0
 No more output streams to write to, finishing.
 [mp4 @ 0000023ce682cd00] Starting second pass: moving the moov atom to the
 beginning of the file
 color primaries unspecified, assuming bt470bg
 [AVIOContext @ 0000023ce6810480] Statistics: 812951190 bytes read, 0 seeks
 frame=67238 fps=204 q=24.0 Lsize=  794542kB time=00:44:49.44
 bitrate=2420.2kbits/s speed=8.14x
 video:666642kB audio:126067kB subtitle:0kB other streams:0kB global
 headers:0kB muxing overhead: 0.231316%
 Input file #0 (D:\temp\SCRATCH\demo1.mpg):
   Input stream #0:0 (video): 67238 packets read (1167445781 bytes); 67238
 frames decoded;
   Input stream #0:1 (audio): 112057 packets read (86059776 bytes); 112057
 frames decoded (129089664 samples);
   Total: 179295 packets (1253505557 bytes) demuxed
 Output file #0 (T:\HDTV\autoTVS-mpg\Converted\demo1.aac.mp4):
   Output stream #0:0 (video): 67238 frames encoded; 67238 packets muxed
 (682641219 bytes);
   Output stream #0:1 (audio): 126065 frames encoded (129089664 samples);
 126067 packets muxed (129092609 bytes);
   Total: 193305 packets (811733828 bytes) muxed
 [Parsed_loudnorm_0 @ 0000023cd92d3680]
 Input Integrated:    -24.2 LUFS
 Input True Peak:      -5.1 dBTP
 Input LRA:             7.3 LU
 Input Threshold:     -34.9 LUFS

 Output Integrated:   -16.0 LUFS
 Output True Peak:     +0.0 dBTP
 Output LRA:            7.0 LU
 Output Threshold:    -26.6 LUFS

 Normalization Type:   Dynamic
 Target Offset:        -0.0 LU
 [AVIOContext @ 0000023cd92db240] Statistics: 30 seeks, 6221 writeouts
 [h264_nvenc @ 0000023cd9326a80] Nvenc unloaded
 [AVIOContext @ 0000023cd92db3c0] Statistics: 1273923728 bytes read, 2
 seeks
 
--------------------------------------------------------------------------------------------------------------
 }}}

--
Ticket URL: <https://trac.ffmpeg.org/ticket/8254#comment:3>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker
_______________________________________________
FFmpeg-trac mailing list
FFmpeg-trac@avcodec.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-trac

To unsubscribe, visit link above, or email
ffmpeg-trac-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to