#8254 closed enhancement (fixed)

ffmpeg encoding with nvenc broken by a commit

Reported by: hydra3333 Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: nvenc enhancement
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hello.
Summary of the bug:
One of these commits "broke" nvenc in ffmpeg when using a 1050Ti :-

13 days ago Timo Rothenpieler avcodec/nvenc: make use of new GetLastErrorString? function commit | commitdiff | tree ab0ef1abdf53e257f7628f2d264adc80038f3bcb
13 days ago Timo Rothenpieler avcodec/nvenc: pass CUstream to nvenc when available commit | commitdiff | tree 51a23343d9c736217d8845b7442fafc373726433
13 days ago Roman Arzumanyan avcodec/nvenc: add multiple reference frames support commit | commitdiff | tree 567b5e33d9d77919ee920c091f4273c5b38fc821
13 days ago Timo Rothenpieler avcodec/nvenc: switch to dedicated dpb_size option commit | commitdiff | tree e929b2f248a9c49761475e07d1a089e05912d1c6

Commit 460f74495fa93c4bb85503c5443580e2bb857efa, which is *just prior* the bottom commit, *works* on both a "1050Ti" and a "2060 Super".

The top commit ab0ef1abdf53e257f7628f2d264adc80038f3bcb

  • *works* on a "2060 Super"
  • *fails* on a "1050Ti" with error "No NVENC capable devices found"

when using identical drivers, input file, commandline, etc.
Both PCs: Win10 Pro x64 fully patched, latest Nvidia driver 436.48, the same copy of ffmpeg.exe built with ab0ef1abdf53e257f7628f2d264adc80038f3bcb
PCs: i4670 with "1050Ti", 3900X with "2060 Super".
ffmpeg cross-compiled on ubuntu.

How to reproduce:

"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -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"  

built on ... using commit ab0ef1abdf53e257f7628f2d264adc80038f3bcb

Logs showing the issue:

  1. from the "1050Ti" failure using commit ab0ef1abdf53e257f7628f2d264adc80038f3bcb

"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -v verbose -init_hw_device list
Supported hardware device types:
cuda
dxva2
qsv
d3d11va
opencl


"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -v verbose -init_hw_device opencl
[AVHWDeviceContext @ 0000026d5440c640] 0.0: NVIDIA CUDA / GeForce? GTX 1050 Ti
[AVHWDeviceContext @ 0000026d5440c640] 1.0: Intel(R) CPU Runtime for OpenCL(TM) Applications / Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
[AVHWDeviceContext @ 0000026d5440c640] 2.0: Intel(R) OpenCL / Intel(R) HD Graphics 4600
[AVHWDeviceContext @ 0000026d5440c640] 2.1: Intel(R) OpenCL / Intel(R) Core(TM) i5-4670 CPU @ 3.40GHz
[AVHWDeviceContext @ 0000026d5440c640] More than one matching device found.
Device creation failed: -19.
Failed to set value 'opencl' for option 'init_hw_device': No such device
Error parsing global options: No such device


"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -v verbose -init_hw_device opencl:0.0
[AVHWDeviceContext @ 0000024a4c3ac6c0] 0.0: NVIDIA CUDA / GeForce? GTX 1050 Ti
[AVHWDeviceContext @ 0000024a4c3ac6c0] DXVA2 to OpenCL mapping function found (clCreateFromDX9MediaSurfaceKHR).
[AVHWDeviceContext @ 0000024a4c3ac6c0] DXVA2 in OpenCL acquire function found (clEnqueueAcquireDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 0000024a4c3ac6c0] DXVA2 in OpenCL release function found (clEnqueueReleaseDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 0000024a4c3ac6c0] The cl_khr_d3d11_sharing extension is required for D3D11 to OpenCL mapping.
[AVHWDeviceContext @ 0000024a4c3ac6c0] D3D11 to OpenCL mapping not usable.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -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"
Routing option strict to both codec and muxer layer
[AVHWDeviceContext @ 000001a18997ef40] 0.0: NVIDIA CUDA / GeForce? GTX 1050 Ti
[AVHWDeviceContext @ 000001a18997ef40] DXVA2 to OpenCL mapping function found (clCreateFromDX9MediaSurfaceKHR).
[AVHWDeviceContext @ 000001a18997ef40] DXVA2 in OpenCL acquire function found (clEnqueueAcquireDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 000001a18997ef40] DXVA2 in OpenCL release function found (clEnqueueReleaseDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 000001a18997ef40] The cl_khr_d3d11_sharing extension is required for D3D11 to OpenCL mapping.
[AVHWDeviceContext @ 000001a18997ef40] D3D11 to OpenCL mapping not usable.
[mpeg @ 000001a18b161c40] 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 @ 000001a19895ba80] w:720 h:576 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:64/45 sws_param:flags=2
[auto_scaler_0 @ 000001a19895a940] w:iw h:ih flags:'bilinear' interl:0
[format @ 000001a18b1d6dc0] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_setdar_5' and the filter 'format'
[Parsed_setdar_5 @ 000001a1987a6200] w:720 h:576 dar:16/9 sar:64/45 -> dar:16/9 sar:64/45
[auto_scaler_0 @ 000001a19895a940] w:720 h:576 fmt:yuv420p sar:64/45 -> w:720 h:576 fmt:nv12 sar:64/45 flags:0x2
[h264_nvenc @ 000001a18b168cc0] Loaded Nvenc version 9.1
[h264_nvenc @ 000001a18b168cc0] Nvenc initialized successfully
[h264_nvenc @ 000001a18b168cc0] 1 CUDA capable devices found
[h264_nvenc @ 000001a18b168cc0] [ GPU #0 - < GeForce? GTX 1050 Ti > has Compute SM 6.1 ]
[h264_nvenc @ 000001a18b168cc0] Multiple reference frames are not supported
[h264_nvenc @ 000001a18b168cc0] No NVENC capable devices found
[h264_nvenc @ 000001a18b168cc0] 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 @ 000001a18b1fad80] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 000001a18b16a640] Statistics: 2642064 bytes read, 2 seeks
Conversion failed!


  1. from the "2060 Super" success using the identical ffmpeg.exe which is commit ab0ef1abdf53e257f7628f2d264adc80038f3bcb

"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -v verbose -init_hw_device list
Supported hardware device types:
cuda
dxva2
qsv
d3d11va
opencl


"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -v verbose -init_hw_device opencl
[AVHWDeviceContext @ 000001e43031c640] 0.0: NVIDIA CUDA / GeForce? RTX 2060 SUPER
[AVHWDeviceContext @ 000001e43031c640] DXVA2 to OpenCL mapping function found (clCreateFromDX9MediaSurfaceKHR).
[AVHWDeviceContext @ 000001e43031c640] DXVA2 in OpenCL acquire function found (clEnqueueAcquireDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 000001e43031c640] DXVA2 in OpenCL release function found (clEnqueueReleaseDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 000001e43031c640] The cl_khr_d3d11_sharing extension is required for D3D11 to OpenCL mapping.
[AVHWDeviceContext @ 000001e43031c640] D3D11 to OpenCL mapping not usable.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -v verbose -init_hw_device opencl:0.0
[AVHWDeviceContext @ 0000020a9b2fc6c0] 0.0: NVIDIA CUDA / GeForce? RTX 2060 SUPER
[AVHWDeviceContext @ 0000020a9b2fc6c0] DXVA2 to OpenCL mapping function found (clCreateFromDX9MediaSurfaceKHR).
[AVHWDeviceContext @ 0000020a9b2fc6c0] DXVA2 in OpenCL acquire function found (clEnqueueAcquireDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 0000020a9b2fc6c0] DXVA2 in OpenCL release function found (clEnqueueReleaseDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 0000020a9b2fc6c0] The cl_khr_d3d11_sharing extension is required for D3D11 to OpenCL mapping.
[AVHWDeviceContext @ 0000020a9b2fc6c0] D3D11 to OpenCL mapping not usable.
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

Use -h to get full help or, even better, run 'man ffmpeg'


"C:\SOFTWARE\ffmpeg\0-homebuilt-x64\ffmpeg.exe" -hide_banner -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"
Routing option strict to both codec and muxer layer
[AVHWDeviceContext @ 000001579131d740] 0.0: NVIDIA CUDA / GeForce? RTX 2060 SUPER
[AVHWDeviceContext @ 000001579131d740] DXVA2 to OpenCL mapping function found (clCreateFromDX9MediaSurfaceKHR).
[AVHWDeviceContext @ 000001579131d740] DXVA2 in OpenCL acquire function found (clEnqueueAcquireDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 000001579131d740] DXVA2 in OpenCL release function found (clEnqueueReleaseDX9MediaSurfacesKHR).
[AVHWDeviceContext @ 000001579131d740] The cl_khr_d3d11_sharing extension is required for D3D11 to OpenCL mapping.
[AVHWDeviceContext @ 000001579131d740] D3D11 to OpenCL mapping not usable.
[mpeg @ 0000015791321940] 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 @ 0000015791354600] w:720 h:576 pixfmt:yuv420p tb:1/90000 fr:25/1 sar:64/45 sws_param:flags=2
[auto_scaler_0 @ 00000157a33af180] w:iw h:ih flags:'bilinear' interl:0
[format @ 00000157913549c0] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_setdar_5' and the filter 'format'
[Parsed_setdar_5 @ 0000015791354340] w:720 h:576 dar:16/9 sar:64/45 -> dar:16/9 sar:64/45
[auto_scaler_0 @ 00000157a33af180] w:720 h:576 fmt:yuv420p sar:64/45 -> w:720 h:576 fmt:nv12 sar:64/45 flags:0x2
[h264_nvenc @ 00000157a2fb7700] Loaded Nvenc version 9.1
[h264_nvenc @ 00000157a2fb7700] Nvenc initialized successfully
[h264_nvenc @ 00000157a2fb7700] 1 CUDA capable devices found
[h264_nvenc @ 00000157a2fb7700] [ GPU #0 - < GeForce? RTX 2060 SUPER > has Compute SM 7.5 ]
[h264_nvenc @ 00000157a2fb7700] supports NVENC
[h264_nvenc @ 00000157a2fb7700] Lookahead enabled: depth 32, scenecut enabled, B-adapt enabled.
[graph_1_in_0_1 @ 00000157a33afb80] tb:1/48000 samplefmt:s16p samplerate:48000 chlayout:0x3
[Parsed_loudnorm_0 @ 00000157a33af680] auto-inserting filter 'auto_resampler_0' between the filter 'graph_1_in_0_1' and the filter 'Parsed_loudnorm_0'
[format_out_0_1 @ 00000157a33ae080] auto-inserting filter 'auto_resampler_1' between the filter 'Parsed_loudnorm_0' and the filter 'format_out_0_1'
[auto_resampler_0 @ 00000157a33aed80] ch:2 chl:stereo fmt:s16p r:48000Hz -> ch:2 chl:stereo fmt:dbl r:192000Hz
[auto_resampler_1 @ 00000157a33ae480] 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 @ 0000015791329b80] ac-tex damaged at 28 27
[mpeg2video @ 0000015791329b80] Warning MVs not available
[mpeg2video @ 0000015791329b80] 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 @ 0000015791358800] Starting second pass: moving the moov atom to the beginning of the file
color primaries unspecified, assuming bt470bg
[AVIOContext @ 0000015791323b80] Statistics: 810591228 bytes read, 0 seeks
frame=67238 fps=283 q=24.0 Lsize= 792990kB time=00:44:49.44 bitrate=2415.4kbits/s speed=11.3x
video:665090kB audio:126067kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.231687%
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 (681052519 bytes);
Output stream #0:1 (audio): 126065 frames encoded (129089664 samples); 126067 packets muxed (129092609 bytes);
Total: 193305 packets (810145128 bytes) muxed

[Parsed_loudnorm_0 @ 00000157a33af680]
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 @ 00000157a2fa0500] Statistics: 30 seeks, 6209 writeouts
[h264_nvenc @ 00000157a2fb7700] Nvenc unloaded
[AVIOContext @ 000001579132b340] Statistics: 1273923728 bytes read, 2 seeks


Change History (11)

comment:1 Changed 12 months ago by cehoyos

  • Keywords regression added
  • Version changed from unspecified to git-master

Why don’t you tell us which commit broke encoding?
Please provide understand that the hide_banner option makes all bug reports invalid.

comment:2 Changed 12 months ago by hydra3333

OK, I'll try each commit and omit --hide_banner an add to this report.

comment:3 Changed 12 months ago 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
-------------------------------------------------------------------------------------------------------------- 

comment:4 Changed 12 months ago by hydra3333

PS Thank you for your wonderful work !!!!!!!!!!!!!!!

comment:5 Changed 12 months ago by heleppkes

That seems like expected behavior. You are requesting a feature to be used which your hardware does not support. Just don't request multiple reference frames, since you hardware is clearly not capable of it.

comment:6 Changed 12 months ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords nvenc added

comment:7 Changed 12 months ago by oromit

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.

comment:8 Changed 12 months ago by hydra3333

Yes. All good.

The error message could be slightly updated to enhance clarity for end-users, however the function does work "as intended".

Cheers !

comment:9 Changed 12 months ago by hydra3333

  • Keywords enhancement added
  • Priority changed from important to normal
  • Type changed from defect to enhancement

Patch submitted, and developer's effective comments are in ffmpeg-devel thread:
http://ffmpeg.org/pipermail/ffmpeg-devel/2019-October/252181.html

comment:10 Changed 12 months ago by hydra3333

  • Keywords regression removed
Note: See TracTickets for help on using tickets.