Opened 22 months ago

Last modified 22 months ago

#10137 open defect

hevc_nvenc [Clipping lookahead depth] and surfaces

Reported by: colemarc Owned by:
Priority: normal Component: avcodec
Version: unspecified Keywords: hevc_nvenc scenecut lookahead clipping surfaces
Cc: colemarc Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
How to reproduce:

Goal: to enable scenecut (IFR frames at scene changes)
Solution: add option -rc-lookahead 59 (cannot find other means)

C:\>ffmpeg -loglevel debug -i Vinyl.S01E06_000520.mkv -to 00:00:01 -an -c:v hevc_nvenc -b_ref_mode 0 -rc-lookahead 59 -pix_fmt yuv420p output.mp4
ffmpeg version N-109527-ga0b5aaceca-20230104 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (crosstool-NG 1.25.0.90_cf9beb1)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --disable-libmfx --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20230104
  libavutil      57. 43.100 / 57. 43.100
  libavcodec     59. 56.100 / 59. 56.100
  libavformat    59. 34.102 / 59. 34.102
  libavdevice    59.  8.101 / 59.  8.101
  libavfilter     8. 53.100 /  8. 53.100
  libswscale      6.  8.112 /  6.  8.112
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    56.  7.100 / 56.  7.100
Splitting the commandline.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument 'debug'.
Reading option '-i' ... matched as input url with argument 'Vinyl.S01E06_000520.mkv'.
Reading option '-to' ... matched as option 'to' (record or transcode stop time) with argument '00:00:01'.
Reading option '-an' ... matched as option 'an' (disable audio) with argument '1'.
Reading option '-c:v' ... matched as option 'c' (codec name) with argument 'hevc_nvenc'.
Reading option '-b_ref_mode' ... matched as AVOption 'b_ref_mode' with argument '0'.
Reading option '-rc-lookahead' ... matched as AVOption 'rc-lookahead' with argument '59'.
Reading option '-pix_fmt' ... matched as option 'pix_fmt' (set pixel format) with argument 'yuv420p'.
Reading option 'output.mp4' ... matched as output url.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option loglevel (set logging level) with argument debug.
Successfully parsed a group of options.
Parsing a group of options: input url Vinyl.S01E06_000520.mkv.
Successfully parsed a group of options.
Opening an input file: Vinyl.S01E06_000520.mkv.
[NULL @ 000001edcbbc9980] Opening 'Vinyl.S01E06_000520.mkv' for reading
[file @ 000001edcbbc9fc0] Setting default whitelist 'file,crypto,data'
[matroska,webm @ 000001edcbbc9980] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
st:1 removing common factor 1000000 from timebase
[matroska,webm @ 000001edcbbc9980] Before avformat_find_stream_info() pos: 2817 bytes read:32768 seeks:0 nb_streams:2
[h264 @ 000001edcd844f80] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 000001edcd844f80] Decoding VUI
[h264 @ 000001edcd844f80] nal_unit_type: 8(PPS), nal_ref_idc: 3
For transform of length 32, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
    1: mdct_inv_float_avx2 - type: mdct_float, len: [16, 8], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
    2: mdct_inv_float_c - type: mdct_float, len: [2, 8], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
    3: mdct_naive_inv_float_c - type: mdct_float, len: [2, 8], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 16, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 2 matches:
    1: fft16_asm_float_fma3 - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 512
    2: fft16_asm_float_avx - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
Transform tree:
    mdct_inv_float_avx2 - type: mdct_float, len: 32, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
        fft16_asm_float_fma3 - type: fft_float, len: 16, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
For transform of length 64, inverse, mdct_float, flags: [aligned, out_of_place], found 3 matches:
    1: mdct_inv_float_avx2 - type: mdct_float, len: [16, 8], factors[2]: [2, any], flags: [aligned, out_of_place, inv_only], prio: 544
    2: mdct_inv_float_c - type: mdct_float, len: [2, 8], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: 96
    3: mdct_naive_inv_float_c - type: mdct_float, len: [2, 8], factors[2]: [2, any], flags: [unaligned, out_of_place, inv_only], prio: -130976
For transform of length 32, inverse, fft_float, flags: [aligned, inplace, preshuf, asm_call], found 2 matches:
    1: fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 512
    2: fft32_asm_float_avx - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call], prio: 480
Transform tree:
    mdct_inv_float_avx2 - type: mdct_float, len: 64, factors[2]: [2, any], flags: [aligned, out_of_place, inv_only]
        fft32_asm_float_fma3 - type: fft_float, len: 32, factor: 2, flags: [aligned, inplace, out_of_place, preshuf, asm_call]
[h264 @ 000001edcd844f80] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 000001edcd844f80] Decoding VUI
[h264 @ 000001edcd844f80] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 000001edcd844f80] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 000001edcd844f80] Format yuv420p chosen by get_format().
[h264 @ 000001edcd844f80] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 000001edcd844f80] no picture
[matroska,webm @ 000001edcbbc9980] All info found
[matroska,webm @ 000001edcbbc9980] After avformat_find_stream_info() pos: 283335 bytes read:315473 seeks:0 frames:8
Input #0, matroska,webm, from 'Vinyl.S01E06_000520.mkv':
  Metadata:
    title           :
    ENCODER         : Lavf58.20.100
  Duration: 00:05:17.03, start: 0.000000, bitrate: 11212 kb/s
  Chapters:
    Chapter #0:0: start 0.000000, end 303.498000
      Metadata:
        title           : 00:01:44.438
    Chapter #0:1: start 303.498000, end 870.731000
      Metadata:
        title           : 00:10:23.498
    Chapter #0:2: start 870.731000, end 1539.733000
      Metadata:
        title           : 00:19:50.731
    Chapter #0:3: start 1539.733000, end 2028.972000
      Metadata:
        title           : 00:30:59.733
    Chapter #0:4: start 2028.972000, end 2415.066000
      Metadata:
        title           : 00:39:08.972
    Chapter #0:5: start 2415.066000, end 2981.298000
      Metadata:
        title           : 00:45:35.066
    Chapter #0:6: start 2981.298000, end 3063.723000
      Metadata:
        title           : 00:55:01.298
  Stream #0:0(eng), 4, 1/1000: Video: h264 (High), 1 reference frame, yuv420p(progressive, left), 1920x1080 (1920x1088), 0/1, SAR 1:1 DAR 16:9, 23.98 fps, 23.98 tbr, 1k tbn (default)
    Metadata:
      BPS             : 8563768
      BPS-eng         : 8563768
      DURATION-eng    : 00:56:23.678000000
      NUMBER_OF_FRAMES: 81127
      NUMBER_OF_FRAMES-eng: 81127
      NUMBER_OF_BYTES : 3622129594
      NUMBER_OF_BYTES-eng: 3622129594
      _STATISTICS_WRITING_APP: mkvmerge v8.3.0 ('Over the Horizon') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v8.3.0 ('Over the Horizon') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-05-20 04:40:35
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-05-20 04:40:35
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:05:17.025000000
  Stream #0:1(eng), 4, 1/1000: Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
    Metadata:
      BPS             : 1508999
      BPS-eng         : 1508999
      DURATION-eng    : 00:56:23.723000000
      NUMBER_OF_FRAMES: 317224
      NUMBER_OF_FRAMES-eng: 317224
      NUMBER_OF_BYTES : 638254688
      NUMBER_OF_BYTES-eng: 638254688
      _STATISTICS_WRITING_APP: mkvmerge v8.3.0 ('Over the Horizon') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v8.3.0 ('Over the Horizon') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-05-20 04:40:35
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-05-20 04:40:35
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:05:16.941000000
Successfully opened the file.
Parsing a group of options: output url output.mp4.
Applying option to (record or transcode stop time) with argument 00:00:01.
Applying option an (disable audio) with argument 1.
Applying option c:v (codec name) with argument hevc_nvenc.
Applying option pix_fmt (set pixel format) with argument yuv420p.
Successfully parsed a group of options.
Opening an output file: output.mp4.
[file @ 000001edcd8b0540] Setting default whitelist 'file,crypto,data'
Successfully opened the file.
detected 8 logical cores
[h264 @ 000001edcdb2eb00] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 000001edcdb2eb00] Decoding VUI
[h264 @ 000001edcdb2eb00] nal_unit_type: 8(PPS), nal_ref_idc: 3
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (hevc_nvenc))
Press [q] to stop, [?] for help
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 1 times
[h264 @ 000001edcdb2eb00] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 000001edcdb2eb00] Format yuv420p chosen by get_format().
[h264 @ 000001edcdb2eb00] Reinit context to 1920x1088, pix_fmt: yuv420p
[h264 @ 000001edcdb2eb00] no picture
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdd40380] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdd40380] no picture
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcd864480] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 4 times
[h264 @ 000001edcdf91f00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdf92600] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdae6e40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdae7800] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdaf81c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdaf89c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
cur_dts is invalid st:0 (0) [init:0 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[h264 @ 000001edcdb2eb00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdd40380] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[graph 0 input from stream 0:0 @ 000001edcd858b80] Setting 'video_size' to value '1920x1080'
[graph 0 input from stream 0:0 @ 000001edcd858b80] Setting 'pix_fmt' to value '0'
[graph 0 input from stream 0:0 @ 000001edcd858b80] Setting 'time_base' to value '1/1000'
[graph 0 input from stream 0:0 @ 000001edcd858b80] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 000001edcd858b80] Setting 'frame_rate' to value '13978/583'
[graph 0 input from stream 0:0 @ 000001edcd858b80] w:1920 h:1080 pixfmt:yuv420p tb:1/1000 fr:13978/583 sar:1/1
[format @ 000001edcd859e80] Setting 'pix_fmts' to value 'yuv420p'
[AVFilterGraph @ 000001edd0943000] query_formats: 5 queried, 4 merged, 0 already done, 0 delayed
[hevc_nvenc @ 000001edcdb2e700] Loaded lib: nvcuda.dll
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: cuInit
[...]
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: cuArrayDestroy
[hevc_nvenc @ 000001edcdb2e700] Cannot load optional cuEGLStreamProducerConnect
[hevc_nvenc @ 000001edcdb2e700] Cannot load optional cuEGLStreamProducerDisconnect
[hevc_nvenc @ 000001edcdb2e700] Cannot load optional cuEGLStreamConsumerDisconnect
[hevc_nvenc @ 000001edcdb2e700] Cannot load optional cuEGLStreamProducerPresentFrame
[hevc_nvenc @ 000001edcdb2e700] Cannot load optional cuEGLStreamProducerReturnFrame
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: cuD3D11GetDevice
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: cuD3D11GetDevices
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: cuGraphicsD3D11RegisterResource
[hevc_nvenc @ 000001edcdb2e700] Loaded lib: nvEncodeAPI64.dll
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: NvEncodeAPICreateInstance
[hevc_nvenc @ 000001edcdb2e700] Loaded sym: NvEncodeAPIGetMaxSupportedVersion
[hevc_nvenc @ 000001edcdb2e700] Loaded Nvenc version 12.0
[hevc_nvenc @ 000001edcdb2e700] Nvenc initialized successfully
[hevc_nvenc @ 000001edcdb2e700] 1 CUDA capable devices found
[hevc_nvenc @ 000001edcdb2e700] [ GPU #0 - < NVIDIA GeForce GTX 1080 Ti > has Compute SM 6.1 ]
[hevc_nvenc @ 000001edcdb2e700] supports NVENC
[hevc_nvenc @ 000001edcdb2e700] Lookahead enabled: depth 58, scenecut enabled, B-adapt disabled.
[hevc_nvenc @ 000001edcdb2e700] Clipping lookahead depth to 58 (from 59) due to lack of surfaces/delayOutput #0, mp4, to 'output.mp4':
  Metadata:
    title           :
    encoder         : Lavf59.34.102
  Chapters:
    Chapter #0:0: start 0.000000, end 1.000000
      Metadata:
        title           : 00:01:44.438
  Stream #0:0(eng), 0, 1/13978: Video: hevc (Main), 1 reference frame (hev1 / 0x31766568), yuv420p(progressive, left), 1920x1080 (0x0) [SAR 1:1 DAR 16:9], 0/1, q=2-31, 2000 kb/s, 23.98 fps, 13978 tbn (default)
    Metadata:
      BPS             : 8563768
      BPS-eng         : 8563768
      DURATION-eng    : 00:56:23.678000000
      NUMBER_OF_FRAMES: 81127
      NUMBER_OF_FRAMES-eng: 81127
      NUMBER_OF_BYTES : 3622129594
      NUMBER_OF_BYTES-eng: 3622129594
      _STATISTICS_WRITING_APP: mkvmerge v8.3.0 ('Over the Horizon') 64bit
      _STATISTICS_WRITING_APP-eng: mkvmerge v8.3.0 ('Over the Horizon') 64bit
      _STATISTICS_WRITING_DATE_UTC: 2016-05-20 04:40:35
      _STATISTICS_WRITING_DATE_UTC-eng: 2016-05-20 04:40:35
      _STATISTICS_TAGS: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      _STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
      DURATION        : 00:05:17.025000000
      encoder         : Lavc59.56.100 hevc_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2000000 buffer size: 4000000 vbv_delay: N/A
Clipping frame in rate conversion by 0.000008
[h264 @ 000001edcd864480] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0N/A
[h264 @ 000001edcdf91f00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
Clipping frame in rate conversion by 0.002998
[h264 @ 000001edcdf92600] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdae6e40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdae7800] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdaf81c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdaf89c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdb2eb00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdd40380] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
Clipping frame in rate conversion by 0.002007
[h264 @ 000001edcd864480] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdf91f00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdf92600] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
Clipping frame in rate conversion by 0.005013
[h264 @ 000001edcdae6e40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdae7800] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdaf81c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdaf89c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
Clipping frame in rate conversion by 0.001015
[h264 @ 000001edcdb2eb00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdd40380] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcd864480] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
Clipping frame in rate conversion by 0.004021
[h264 @ 000001edcdf91f00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdf92600] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdae6e40] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 0
[h264 @ 000001edcdae7800] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[h264 @ 000001edcdaf81c0] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
[out_0_0 @ 000001edcd858c80] EOF on sink link out_0_0:default.
No more output streams to write to, finishing.
All streams finished for output file #0
Terminating muxer thread 0
[AVIOContext @ 000001edcd8b29c0] Statistics: 296131 bytes written, 2 seeks, 5 writeouts
frame=   24 fps=0.0 q=27.0 Lsize=     289kB time=00:00:00.95 bitrate=2469.5kbits/s speed=1.71x
video:288kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.564072%
Input file #0 (Vinyl.S01E06_000520.mkv):
  Input stream #0:0 (video): 35 packets read (1446755 bytes); 26 frames decoded;
  Input stream #0:1 (audio): 4 packets read (8048 bytes);
  Total: 39 packets (1454803 bytes) demuxed
Output file #0 (output.mp4):
  Output stream #0:0 (video): 24 frames encoded; 24 packets muxed (294466 bytes);
  Total: 24 packets (294466 bytes) muxed
26 frames successfully decoded, 0 decoding errors
[hevc_nvenc @ 000001edcdb2e700] Nvenc unloaded
Terminating demuxer thread 0
[AVIOContext @ 000001edcbbca2c0] Statistics: 1794301 bytes read, 0 seeks

Please notice: Clipping lookahead depth to 58 (from 59) due to lack of surfaces/delay

Adding option: -surfaces 64

C:\>ffmpeg -loglevel debug -i Vinyl.S01E06_000520.mkv -to 00:00:01 -an -c:v hevc_nvenc -b_ref_mode 0 -surfaces 64 -rc-lookahead 59 -pix_fmt yuv420p output.mp4
[...Same log as before, until:]
[hevc_nvenc @ 000001c1bb8b9800] Loaded Nvenc version 12.0
[hevc_nvenc @ 000001c1bb8b9800] Nvenc initialized successfully
[hevc_nvenc @ 000001c1bb8b9800] 1 CUDA capable devices found
[hevc_nvenc @ 000001c1bb8b9800] [ GPU #0 - < NVIDIA GeForce GTX 1080 Ti > has Compute SM 6.1 ]
[hevc_nvenc @ 000001c1bb8b9800] supports NVENC
[hevc_nvenc @ 000001c1bb8b9800] Defined rc_lookahead requires more surfaces, increasing used surfaces 64 -> 65
[hevc_nvenc @ 000001c1bb8b9800] Lookahead enabled: depth 58, scenecut enabled, B-adapt disabled.
[hevc_nvenc @ 000001c1bb8b9800] Clipping lookahead depth to 58 (from 59) due to lack of surfaces/delayOutput #0, mp4, to 'output.mp4':
[...]

Please notice: Defined rc_lookahead requires more surfaces, increasing used surfaces 64 -> 65
Please notice: Clipping lookahead depth to 58 (from 59) due to lack of surfaces/delay

Changing to: -surfaces 100

C:\>ffmpeg -loglevel debug -i Vinyl.S01E06_000520.mkv -to 00:00:01 -an -c:v hevc_nvenc -b_ref_mode 0 -surfaces 100 -rc-lookahead 59 -pix_fmt yuv420p output.mp4
[...Same log as before, until:]
[hevc_nvenc @ 000002767b2c9800] Loaded Nvenc version 12.0
[hevc_nvenc @ 000002767b2c9800] Nvenc initialized successfully
[hevc_nvenc @ 000002767b2c9800] 1 CUDA capable devices found
[hevc_nvenc @ 000002767b2c9800] [ GPU #0 - < NVIDIA GeForce GTX 1080 Ti > has Compute SM 6.1 ]
[hevc_nvenc @ 000002767b2c9800] supports NVENC
[hevc_nvenc @ 000002767b2c9800] Defined rc_lookahead requires more surfaces, increasing used surfaces 64 -> 65
[hevc_nvenc @ 000002767b2c9800] Lookahead enabled: depth 58, scenecut enabled, B-adapt disabled.
[hevc_nvenc @ 000002767b2c9800] Clipping lookahead depth to 58 (from 59) due to lack of surfaces/delayOutput #0, mp4, to 'output.mp4':
[...]
hevc_nvenc @ 000001eff9e2fc00] Value 100.000000 for parameter 'surfaces' out of range [0 - 64]
[hevc_nvenc @ 000001eff9e2fc00] Error setting option surfaces to value 100.
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

Please notice: Defined rc_lookahead requires more surfaces, increasing used surfaces 64 -> 65
Please notice: Clipping lookahead depth to 58 (from 59) due to lack of surfaces/delay
Please notice: Value 100.000000 for parameter 'surfaces' out of range [0 - 64]

So, max surfaces number seems to be 64 (documented by ffmpeg -h encoder=hevc_nvenc) but then it is nonetheless apparently increased to 65 (???)

Also, if I set -surfaces 64 -rc-lookahead 100 then the message before Clipping lookahead depth... becomes Defined rc_lookahead requires more surfaces, increasing used surfaces 64 -> 165.

If I set -surfaces 64 -rc-lookahead 58 then there is no warning message about surfaces or lookahead clipping.

Change History (6)

comment:1 by colemarc, 22 months ago

Status: newopen

comment:2 by quinkblack, 22 months ago

From "NVIDIA VIDEO CODEC SDK - ENCODER Programming Guide",

The number of frames to be looked ahead should be set in NV_ENC_INITIALIZE_PARAMS::encodeconfig->rcParams.lookaheadDepth which can be up to 32.

From nvEncodeAPI.h:

    uint16_t                        lookaheadDepth;                              /**< [in]: Maximum depth of lookahead with range 0-(31 - number of B frames).
                                                                                            lookaheadDepth is only used if enableLookahead=1.*/

You don't need a super large lookahead to enable scenecut. -rc-lookahead 1 works for scenecut. You can verify it by a super large gop size, for example,

ffmpeg -hwaccel cuda -i ~/video/cctv.mp4 -an -c:v hevc_nvenc -rc-lookahead 1 -b:v 3M -t 60 -g 2500 /tmp/test.mp4
Last edited 22 months ago by quinkblack (previous) (diff)

in reply to:  2 comment:3 by colemarc, 22 months ago

Replying to quinkblack:

Thank you, much appreciated.

I believe I should leave this ticket open since the warning messages are at least inconsistent.

comment:4 by quinkblack, 22 months ago

For encoders, different parameters can affect each other. It's not straight forward to figure it out. Encoding is complex by itself, I won't take much time on this unless there is a serious issue. Good luck.

in reply to:  4 ; comment:5 by colemarc, 22 months ago

Replying to quinkblack:
It seems to me that hevc_nvenc scenecut detection is rather shallow.
I mean, very hard cuts are rendered as key frames, but a scene cut involving adiacent frames having similar colors is not (even if the pictures are completely different in terms of Mean Square Error).
Do you happen to know if it can be made more sensitive?
Could option -b_ref_mode 0 interfere with scenecut detection?

Last edited 22 months ago by colemarc (previous) (diff)

in reply to:  5 comment:6 by quinkblack, 22 months ago

Replying to colemarc:

Replying to quinkblack:
It seems to me that hevc_nvenc scenecut detection is rather shallow.
I mean, very hard cuts are rendered as key frames, but a scene cut involving adiacent frames having similar colors is not (even if the pictures are completely different in terms of Mean Square Error).
Do you happen to know if it can be made more sensitive?
Could option -b_ref_mode 0 interfere with scenecut detection?

I don't know how to set scenecut threshold for nvenc, but you can set frmae->pict_type and implement scenecut your self.

Note: See TracTickets for help on using tickets.