Opened 5 months ago

Last modified 4 months ago

#7753 new defect

yadif_cuda fails, with h264_cuvid decoder

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

Description

Summary of the bug: Trying to use yadif_cuda. It works fine for an mpeg2ts file, using the HW decoder mpeg2_cuvid ... but try the same thing on an H.264 input, and using h264_cuvid, then it fails.

How to reproduce:

% ffmpeg -threads 0 -hwaccel cuvid -c:v h264_cuvid -y -i input.MTS -vf yadif_cuda,scale_npp=1280:-1 -c:v hevc_nvenc -preset slow -cq 10 -g 150 -c:a aac -b:a 128k -metadata:s:a:0 language=eng output.mp4
ffmpeg version n4.1.1
built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)

Error message(s) ...

Parsed_yadif_cuda_0 @ 0x56524b398000] cuModuleLoadData(&s->cu_module, vf_yadif_cuda_ptx) failed -> CUDA_ERROR_UNKNOWN: unknown error
[Parsed_yadif_cuda_0 @ 0x56524b398000] Failed to configure output pad on Parsed_yadif_cuda_0
Error reinitializing filters!
Failed to inject frame into filter network: Invalid data found when processing input
Error while processing the decoded data for stream #0:0

Change History (11)

comment:1 Changed 5 months ago by cehoyos

  • Component changed from ffmpeg to undetermined
  • Keywords cuda added; yadif_cuda h264_cuvid removed
  • Version changed from 4.1 to unspecified

Please test current FFmpeg git head and provide the command line you tested together with the complete, uncut console output to make this a valid ticket.

comment:2 Changed 5 months ago by arrmo

Hi,

I tried running the git head before reverting to n4.1.1, due to the issue noted here, https://trac.ffmpeg.org/ticket/7742. This seems to say it's corrected, but when I try to build with the git head I run into this problem (i.e. compile fails).

I'm more than happy to update this with the latest build, once of course I can get that to build (i.e. need the noted item resolved first).

Thanks!

comment:3 Changed 5 months ago by philipl

I've pushed the fix for master so you can retest there. The error you are getting is strange - the key point is the failed cuModuleLoadData call - that means the cuda kernel cannot be loaded, but this should either always fail or never fail - the mpeg2 vs h.264 is irrelevant here.

For what it's worth, I can run that command line just fine locally for both mpeg2 and h.264.

You should probably also use nvdec instead of cuvid.

comment:4 Changed 5 months ago by arrmo

Yes, you are correct - I pulled the master, and now it builds. Thanks!

OK, very odd, but cuvid vs. nvdec react differently (more, below). They both fail, but in different ways. BTW .. what is the difference? Just trying to understand.

Here is the difference (providing full command line - I can attach full logs if you want too, no issue!),
1) /mnt/ProgSSD/FFmpeg/ffmpeg -threads 0 -hwaccel cuvid -c:v h264_cuvid -y -i "/mnt/ProgSSD/transcodeAVCHD/test/00005.MTS" -vf yadif_cuda,scale_npp=1280:-1 -c:v hevc_nvenc -preset slow -cq 10 -g 150 -c:a aac -b:a 128k -metadata:s:a:0 language=eng "/mnt/ProgSSD/transcodeAVCHD/test/test1.mp4"

ffmpeg version N-93231-g96d79ff5b5 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)
  configuration: --enable-libnpp --enable-nonfree --enable-cuda --enable-libx264 --enable-gpl --enable-nvenc --enable-libx265 --enable-cuda-sdk --enable-cuvid
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 47.102 / 58. 47.102
  libavformat    58. 26.101 / 58. 26.101
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mpegts, from '/mnt/ProgSSD/transcodeAVCHD/test/00005.MTS':
  Duration: 00:00:15.04, start: 1.033367, bitrate: 16837 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
[Parsed_yadif_cuda_0 @ 0x56535d4c27c0] cuModuleLoadData(&s->cu_module, vf_yadif_cuda_ptx) failed -> CUDA_ERROR_UNKNOWN: unknown error
[Parsed_yadif_cuda_0 @ 0x56535d4c27c0] Failed to configure output pad on Parsed_yadif_cuda_0
Error reinitializing filters!
Failed to inject frame into filter network: Generic error in an external library
Error while processing the decoded data for stream #0:0

2) /mnt/ProgSSD/FFmpeg/ffmpeg -threads 0 -hwaccel nvdec -c:v h264_cuvid -y -i "/mnt/ProgSSD/transcodeAVCHD/test/00005.MTS" -vf yadif_cuda,scale_npp=1280:-1 -c:v hevc_nvenc -preset slow -cq 10 -g 150 -c:a aac -b:a 128k -metadata:s:a:0 language=eng "/mnt/ProgSSD/transcodeAVCHD/test/test1.mp4"

ffmpeg version N-93231-g96d79ff5b5 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)
  configuration: --enable-libnpp --enable-nonfree --enable-cuda --enable-libx264 --enable-gpl --enable-nvenc --enable-libx265 --enable-cuda-sdk --enable-cuvid
  libavutil      56. 26.100 / 56. 26.100
  libavcodec     58. 47.102 / 58. 47.102
  libavformat    58. 26.101 / 58. 26.101
  libavdevice    58.  6.101 / 58.  6.101
  libavfilter     7. 48.100 /  7. 48.100
  libswscale      5.  4.100 /  5.  4.100
  libswresample   3.  4.100 /  3.  4.100
  libpostproc    55.  4.100 / 55.  4.100
Input #0, mpegts, from '/mnt/ProgSSD/transcodeAVCHD/test/00005.MTS':
  Duration: 00:00:15.04, start: 1.033367, bitrate: 16837 kb/s
  Program 1
    Stream #0:0[0x1011]: Video: h264 (High) (HDMV / 0x564D4448), yuv420p(top first), 1920x1080 [SAR 1:1 DAR 16:9], 29.97 fps, 59.94 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x1100]: Audio: ac3 (AC-3 / 0x332D4341), 48000 Hz, stereo, fltp, 256 kb/s
    Stream #0:2[0x1200]: Subtitle: hdmv_pgs_subtitle ([144][0][0][0] / 0x0090), 1920x1080
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> hevc (hevc_nvenc))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
Impossible to convert between the formats supported by the filter 'graph 0 input from stream 0:0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0

comment:5 Changed 5 months ago by philipl

You would use nvdec with "-hwaccel nvdec -hwaccel_output_format cuda" and not specifying the input codec. nvdec is a proper hwaccel implementation while cuvid is a full decoder implementation using the nvidia parser.

Not that I expect you to see different results in each case. As I said, the error doesn't really make sense - cuModuleLoadData should not fail, and certainly should not fail selectively.

comment:6 Changed 5 months ago by arrmo

Yes, agreed - makes sense, thanks!

Please let me know if there is anything at all you want me to try here.

comment:7 Changed 5 months ago by arrmo

FYI, if I use the command noted above "-hwaccel nvdec -hwaccel_output_format cuda", and don't specify the input codec => then I get the same error as in case #1 (cuModuleLoadData(&s->cu_module, vf_yadif_cuda_ptx) failed -> CUDA_ERROR_UNKNOWN: unknown error)

Thoughts?

Thanks!

comment:8 Changed 5 months ago by arrmo

Hi,

OK, I got approach #1 working, but only with sudo in front of the command. Huh? ... ;-). cuvid requires sudo, but not nvdec?

Thanks!

comment:9 Changed 5 months ago by philipl

Sounds like you have incorrect permissions on your /dev/nvidia*. Set them to 666 and try again. Both should work, without sudo.

comment:10 Changed 5 months ago by arrmo

Seems to work with that fix, thanks!!!

So to above, still a but confused about the difference between hwaccels (cuvid and nvdec) - they seem to be very similar, just different outputs ... and compatibility with those outputs is confusing (to say the least ... LOL). Is this explained / captured somewhere?

Thanks again!

comment:11 Changed 4 months ago by philipl

You can read https://trac.ffmpeg.org/wiki/HWAccelIntro for some details.

The main difference is that nvdec implements a proper hwaccel that hooks into the primary ffmpeg decoders (like dxva, vdpau, vaapi, etc) while cuvid is a wrapper around a full decoder implementation from nvidia. That means it cannot take advantaging of any of ffmpeg's bitstream parsing or other features, which is a problem in some situations (eg: 10bit hdr will not decode correctly). On the other hand, cuvid provides access to nvidia's own deinterlacer and you don't need yadif_cuda.

Note: See TracTickets for help on using tickets.