Opened 2 years ago

#9664 new defect

Neverending loop in transcoding via CUDA after frame size change

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

Description

I have a video file (I cannot share unfortunatelly) and after ~1-2 minutes frame sizes change from 1280x720 to 1920x1088. Would be great if FFmpeg exits with an error code instead of ending in neverending loop and spamming

[h264_cuvid @ 0x1c079c0] ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams) failed -> CUDA_ERROR_INVALID_HANDLE: invalid resource handle
[h264_cuvid @ 0x1c079c0] cuvid decode callback error
Error while decoding stream #0:0: Generic error in an external library

Used command:

ffmpeg -loglevel 40  \
 -f 'mp4' -hwaccel cuvid -hwaccel_device 0 -hwaccel_output_format cuda \
 -c:v h264_cuvid -i 'input.mp4' \
 -filter_complex "[0:0]scale_npp=-2:720:format=same:interp_algo=super,setsar=1/1:max=1000[_map_5]" \
 -map '[_map_5]' -noautoscale -f 'hls' -y -map_metadata -1 \
 -hls_time 5 -hls_allow_cache 0 -hls_playlist_type event \
 -hls_flags independent_segments -hls_segment_filename "/tmp/mrsk/720p/segment_%05d.ts" \
 -master_pl_name 'master.m3u8' -c:v h264_nvenc -preset fast -g 125 -r:v 25 \
 -b:v 2400k -bufsize 4800k '/tmp/mrsk/720p/playlist.m3u8'

Output:

ffmpeg version 5.0 Copyright (c) 2000-2022 the FFmpeg developers
  built with gcc 4.9.4 (Ubuntu 4.9.4-2ubuntu1~12.04)
  configuration: --prefix=/opt/ffmpeg/5.0/build --cc= --cxx= --objcc= --dep-cc= --extra-cflags=' -I/usr/local/cuda-10.1/include' --extra-cxxflags= --extra-ldflags='-Wl,-rpath,/opt/ffmpeg/5.0/build/lib -L/opt/ffmpeg/5.0/build/lib -Wl,-rpath,/usr/local/cuda-10.1/lib64 -L/usr/local/cuda-10.1/lib64' --bindir=/opt/ffmpeg/5.0/build/bin --enable-shared --disable-static --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --enable-cuda-nvcc --enable-gpl --enable-libaom --enable-libfdk-aac --enable-libmp3lame --enable-libnpp --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-nonfree --enable-nvdec --enable-nvenc --enable-openssl --enable-rpath --enable-version3
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
[h264 @ 0x1bedf80] Reinit context to 1280x720, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
  Duration: 00:11:37.40, start: 0.012000, bitrate: 8303 kb/s
  Stream #0:0[0x1](und): Video: h264 (Main), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 1280x720 [SAR 1:1 DAR 16:9], 8301 kb/s, 25 fps, 25 tbr, 90k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
[h264_cuvid @ 0x1c079c0] CUVID capabilities for h264_cuvid:
[h264_cuvid @ 0x1c079c0] 8 bit: supported: 1, min_width: 48, max_width: 4096, min_height: 16, max_height: 4096
[h264_cuvid @ 0x1c079c0] 10 bit: supported: 0, min_width: 0, max_width: 0, min_height: 0, max_height: 0
[h264_cuvid @ 0x1c079c0] 12 bit: supported: 0, min_width: 0, max_width: 0, min_height: 0, max_height: 0
Stream mapping:
  Stream #0:0 (h264_cuvid) -> scale_npp:default
  setsar:default -> Stream #0:0 (h264_nvenc)
Press [q] to stop, [?] for help
[h264_cuvid @ 0x1c079c0] Formats: Original: cuda | HW: cuda | SW: nv12
[graph 0 input from stream 0:0 @ 0x25f37c0] w:1280 h:720 pixfmt:cuda tb:1/90000 fr:25/1 sar:1/1
[Parsed_scale_npp_0 @ 0x1c58100] w:1280 h:720 -> w:1280 h:720
[Parsed_setsar_1 @ 0x25f2700] w:1280 h:720 sar:1/1 dar:16/9 -> sar:1/1 dar:16/9
[h264_nvenc @ 0x1bf4980] Using input frames context (format cuda) with h264_nvenc encoder.
[h264_nvenc @ 0x1bf4980] Loaded Nvenc version 9.0
[h264_nvenc @ 0x1bf4980] Nvenc initialized successfully
[mpegts @ 0x2a334c0] service 1 using PCR in pid=256, pcr_period=0ms
[mpegts @ 0x2a334c0] muxrate VBR, sdt every 1073741822000 ms, pat/pmt every 1073741822000 ms
Output #0, hls, to '/tmp/mrsk/720p/playlist.m3u8':
  Metadata:
    encoder         : Lavf59.16.100
  Stream #0:0: Video: h264 (Main), 1 reference frame, cuda(tv, progressive, left), 1280x720 (0x0) [SAR 1:1 DAR 16:9], q=2-31, 2400 kb/s, 25 fps, 90k tbn
    Metadata:
      encoder         : Lavc59.18.100 h264_nvenc
    Side data:
      cpb: bitrate max/min/avg: 0/0/2400000 buffer size: 4800000 vbv_delay: N/A
frame=    1 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A speed=   0x    
[hls @ 0x1bf6140] Opening '/tmp/mrsk/720p/segment_00000.ts' for writing
[AVIOContext @ 0x2a55ac0] Statistics: 1627892 bytes written, 0 seeks, 7 writeouts
[hls @ 0x1bf6140] Opening '/tmp/mrsk/720p/playlist.m3u8.tmp' for writing
EXT-X-MEDIA-SEQUENCE:0
... processing ...
[hls @ 0x1bf6140] Opening '/tmp/mrsk/720p/segment_00018.ts' for writing
[AVIOContext @ 0x2a55d80] Statistics: 1351344 bytes written, 0 seeks, 6 writeouts
[hls @ 0x1bf6140] Opening '/tmp/mrsk/720p/playlist.m3u8.tmp' for writing
EXT-X-MEDIA-SEQUENCE:0
[AVIOContext @ 0x2a55c00] Statistics: 815 bytes written, 0 seeks, 1 writeouts
[h264_cuvid @ 0x1c079c0] Formats: Original: cuda | HW: cuda | SW: nv12
[h264_cuvid @ 0x1c079c0] AVHWFramesContext is already initialized with incompatible parameters
[h264_cuvid @ 0x1c079c0] ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams) failed -> CUDA_ERROR_INVALID_HANDLE: invalid resource handle
[h264_cuvid @ 0x1c079c0] cuvid decode callback error
Error while decoding stream #0:0: Generic error in an external library
[h264_cuvid @ 0x1c079c0] ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams) failed -> CUDA_ERROR_INVALID_HANDLE: invalid resource handle
[h264_cuvid @ 0x1c079c0] cuvid decode callback error
Error while decoding stream #0:0: Generic error in an external library
[h264_cuvid @ 0x1c079c0] ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams) failed -> CUDA_ERROR_INVALID_HANDLE: invalid resource handle
[h264_cuvid @ 0x1c079c0] cuvid decode callback error
Error while decoding stream #0:0: Generic error in an external library
... neverending loop ...

Change History (0)

Note: See TracTickets for help on using tickets.