Opened 7 years ago
Closed 7 years ago
#7778 closed defect (invalid)
Visual artifacts when decoding with h264_cuvid
| Reported by: | Ilya87 | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | git-master | Keywords: | cuvid |
| Cc: | Blocked By: | ||
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | no |
Description
Visualartifacts appear when decoding with cuvid, not with h264 software decooder. File is lossles h264, created with
-c:v libx264 -preset medium -crf 0 command.
How to reproduce:
% ffplay -loglevel debug -vcodec h264_cuvid /home/ilya/sample.mkv
ffplay version N-93302-g147ef1d947 Copyright (c) 2003-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181127
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-libvmaf --extra-cflags='-march=native -mtune=native -g0 -O3' --extra-cxxflags='-march=native -mtune=native -g0 -O3' --enable-version3
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.103 / 58. 47.103
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, matroska,webm, from '/home/ilya/sample.mkv': 0B f=0/0
Metadata:
encoder : libebml v1.3.6 + libmatroska v1.4.9
creation_time : 2019-03-08T18:53:31.000000Z
Duration: 00:00:49.63, start: 0.000000, bitrate: 30671 kb/s
Stream #0:0: Video: h264 (High 4:4:4 Predictive), yuv420p(progressive), 1132x482 [SAR 1:1 DAR 566:241], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
BPS-eng : 30668755
DURATION-eng : 00:00:49.633000000
NUMBER_OF_FRAMES-eng: 1190
NUMBER_OF_BYTES-eng: 190272794
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-03-08 18:53:31
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
nan M-V: nan fd= 0 aq= 0KB vq= 4446KB sq= 0B f=0/0
[ilya@FORTRESS ~]$ ffplay -loglevel debug -vcodec h264_cuvid /home/ilya/sample.mkv
ffplay version N-93302-g147ef1d947 Copyright (c) 2003-2019 the FFmpeg developers
built with gcc 8.2.1 (GCC) 20181127
configuration: --prefix=/usr --disable-debug --disable-static --disable-stripping --enable-fontconfig --enable-gmp --enable-gnutls --enable-gpl --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi --enable-libgsm --enable-libiec61883 --enable-libjack --enable-libmodplug --enable-libmp3lame --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxcb --enable-libxml2 --enable-libxvid --enable-nvdec --enable-nvenc --enable-omx --enable-shared --enable-libvmaf --extra-cflags='-march=native -mtune=native -g0 -O3' --extra-cxxflags='-march=native -mtune=native -g0 -O3' --enable-version3
libavutil 56. 26.100 / 56. 26.100
libavcodec 58. 47.103 / 58. 47.103
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
Initialized opengl renderer.
[NULL @ 0x7f1d34000b80] Opening '/home/ilya/sample.mkv' for reading
[file @ 0x7f1d34001740] Setting default whitelist 'file,crypto'
[matroska,webm @ 0x7f1d34000b80] Format matroska,webm probed with size=2048 and score=100
st:0 removing common factor 1000000 from timebase
[matroska,webm @ 0x7f1d34000b80] Before avformat_find_stream_info() pos: 5495 bytes read:33164 seeks:2 nb_streams:1
[h264 @ 0x7f1d34004e00] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x7f1d34004e00] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x7f1d34004e00] nal_unit_type: 7(SPS), nal_ref_idc: 3
[h264 @ 0x7f1d34004e00] nal_unit_type: 8(PPS), nal_ref_idc: 3
[h264 @ 0x7f1d34004e00] nal_unit_type: 6(SEI), nal_ref_idc: 0
[h264 @ 0x7f1d34004e00] nal_unit_type: 5(IDR), nal_ref_idc: 3
[h264 @ 0x7f1d34004e00] Format yuv420p chosen by get_format().
[h264 @ 0x7f1d34004e00] Reinit context to 1136x496, pix_fmt: yuv420p
[h264 @ 0x7f1d34004e00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
Last message repeated 2 times
[h264 @ 0x7f1d34004e00] nal_unit_type: 1(Coded slice of a non-IDR picture), nal_ref_idc: 2
Last message repeated 2 times
[matroska,webm @ 0x7f1d34000b80] All info foundKB sq= 0B f=0/0
[matroska,webm @ 0x7f1d34000b80] After avformat_find_stream_info() pos: 1040540 bytes read:1068209 seeks:2 frames:8
Input #0, matroska,webm, from '/home/ilya/sample.mkv':
Metadata:
encoder : libebml v1.3.6 + libmatroska v1.4.9
creation_time : 2019-03-08T18:53:31.000000Z
Duration: 00:00:49.63, start: 0.000000, bitrate: 30671 kb/s
Stream #0:0, 8, 1/1000: Video: h264 (High 4:4:4 Predictive), 1 reference frame, yuv420p(progressive, left), 1132x482 (1136x496) [SAR 1:1 DAR 566:241], 0/1, 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
Metadata:
BPS-eng : 30668755
DURATION-eng : 00:00:49.633000000
NUMBER_OF_FRAMES-eng: 1190
NUMBER_OF_BYTES-eng: 190272794
_STATISTICS_WRITING_APP-eng: mkvmerge v31.0.0 ('Dolores In A Shoestand') 64-bit
_STATISTICS_WRITING_DATE_UTC-eng: 2019-03-08 18:53:31
_STATISTICS_TAGS-eng: BPS DURATION NUMBER_OF_FRAMES NUMBER_OF_BYTES
[h264_cuvid @ 0x7f1d340090c0] Format nv12 chosen by get_format().
[h264_cuvid @ 0x7f1d340090c0] Loaded lib: libnvcuvid.so.1
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidGetDecoderCaps
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCreateDecoder
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidDestroyDecoder
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidDecodePicture
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidGetDecodeStatus
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidReconfigureDecoder
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidMapVideoFrame64
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidUnmapVideoFrame64
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCtxLockCreate
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCtxLockDestroy
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCtxLock
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCtxUnlock
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCreateVideoSource
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCreateVideoSourceW
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidDestroyVideoSource
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidSetVideoSourceState
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidGetVideoSourceState
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidGetSourceVideoFormat
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidGetSourceAudioFormat
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidCreateVideoParser
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidParseVideoData
[h264_cuvid @ 0x7f1d340090c0] Loaded sym: cuvidDestroyVideoParser
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded lib: libcuda.so.1
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuInit
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDeviceGetCount
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDeviceGet
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDeviceGetAttribute
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDeviceGetName
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDeviceComputeCapability
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuCtxCreate_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuCtxSetLimit
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuCtxPushCurrent_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuCtxPopCurrent_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuCtxDestroy_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMemAlloc_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMemAllocPitch_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMemsetD8Async
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMemFree_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMemcpy2D_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMemcpy2DAsync_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGetErrorName
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGetErrorString
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuStreamCreate
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuStreamQuery
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuStreamSynchronize
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuStreamDestroy_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuStreamAddCallback
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuEventCreate
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuEventDestroy_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuEventSynchronize
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuEventQuery
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuEventRecord
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuLaunchKernel
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuModuleLoadData
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuModuleUnload
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuModuleGetFunction
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuTexObjectCreate
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuTexObjectDestroy
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGLGetDevices_v2
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGraphicsGLRegisterImage
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGraphicsUnregisterResource
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGraphicsMapResources
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGraphicsUnmapResources
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuGraphicsSubResourceGetMappedArray
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDeviceGetUuid
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuImportExternalMemory
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDestroyExternalMemory
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuExternalMemoryGetMappedBuffer
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuExternalMemoryGetMappedMipmappedArray
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMipmappedArrayGetLevel
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuMipmappedArrayDestroy
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuImportExternalSemaphore
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuDestroyExternalSemaphore
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuSignalExternalSemaphoresAsync
[AVHWDeviceContext @ 0x7f1d346d2580] Loaded sym: cuWaitExternalSemaphoresAsync
[h264_cuvid @ 0x7f1d340090c0] CUVID capabilities for h264_cuvid:
[h264_cuvid @ 0x7f1d340090c0] 8 bit: supported: 1, min_width: 48, max_width: 4096, min_height: 16, max_height: 4096
[h264_cuvid @ 0x7f1d340090c0] 10 bit: supported: 0, min_width: 0, max_width: 0, min_height: 0, max_height: 0
[h264_cuvid @ 0x7f1d340090c0] 12 bit: supported: 0, min_width: 0, max_width: 0, min_height: 0, max_height: 0
[h264_cuvid @ 0x7f1d340090c0] Format nv12 chosen by get_format().
[h264_cuvid @ 0x7f1d340090c0] Formats: Original: nv12 | HW: nv12 | SW: nv12
Video frame changed from size:0x0 format:none serial:-1 to size:1132x482 format:nv12 serial:1
detected 6 logical cores
[ffplay_buffer @ 0x7f1cfc2ede40] Setting 'video_size' to value '1132x482'
[ffplay_buffer @ 0x7f1cfc2ede40] Setting 'pix_fmt' to value '23'
[ffplay_buffer @ 0x7f1cfc2ede40] Setting 'time_base' to value '1/1000'
[ffplay_buffer @ 0x7f1cfc2ede40] Setting 'pixel_aspect' to value '1/1'
[ffplay_buffer @ 0x7f1cfc2ede40] Setting 'frame_rate' to value '24000/1001'
[ffplay_buffer @ 0x7f1cfc2ede40] w:1132 h:482 pixfmt:nv12 tb:1/1000 fr:24000/1001 sar:1/1 sws_param:
[auto_scaler_0 @ 0x7f1cfc2efa00] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x7f1cfc2efa00] w:iw h:ih flags:'bicubic' interl:0
[ffplay_buffersink @ 0x7f1cfc2eeb80] auto-inserting filter 'auto_scaler_0' between the filter 'ffplay_buffer' and the filter 'ffplay_buffersink'
[AVFilterGraph @ 0x7f1cfc2ecd80] query_formats: 2 queried, 0 merged, 1 already done, 0 delayed
[auto_scaler_0 @ 0x7f1cfc2efa00] picking yuv420p out of 2 ref:nv12 alpha:0
[auto_scaler_0 @ 0x7f1cfc2efa00] w:1132 h:482 fmt:nv12 sar:1/1 -> w:1132 h:482 fmt:yuv420p sar:1/1 flags:0x4
Created 1132x482 texture with SDL_PIXELFORMAT_IYUV.
[AVIOContext @ 0x7f1d34009bc0] Statistics: 8325303 bytes read, 2 seeks
ffmpeg version N-93302-g147ef1d947
built on Antegros Linux x86_64
Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.
Attachments (1)
Change History (16)
by , 7 years ago
| Attachment: | artifacts.png added |
|---|
comment:1 by , 7 years ago
comment:2 by , 7 years ago
| Keywords: | cuvid added |
|---|
Is cuvid supposed to support lossless h264? If yes, is this an issue that can be fixed in FFmpeg?
I thought lossless h264 means additional license costs and additional complexity.
comment:3 by , 7 years ago
Yes, cuvid supports lossless H.264 and also I can decode High 4:4:4 Predictive@L5 video with 2560x1090. This one is High 4:4:4 Predictive@L3.1.
comment:4 by , 7 years ago
You should try the NVDEC hwaccel. Thats the one we actually have control over. h264_cuvid passes the entire stream to the NVIDIA parser and hopes for the best.
comment:5 by , 7 years ago
@heleppkes,
ffmpeg -codecs
h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m h264_cuvid )
Which of decoders for h/w acceleration should I use?
comment:6 by , 7 years ago
I can see the artifacts with cuvid in mpv too. It's not a big surprise, given the limitations in the nvidia parser. As hleppkes says, you should use nvdec. I'm not sure if ffplay supports hwaccels - at least I can't see how to activate them.
I'd recommend using a real media player like mpv if you want to play back the file (of course, ffmpeg can do hwaccel decoding for transcoding purposes, etc).
ffmpeg -hwaccel nvdec -hwaccel_output_format cuda <etc>
Separately, I don't understand what 420 subsampling in a high444p profile file means - the nvidia decoder definitely can't handle actual 444 subsampling.
comment:7 by , 7 years ago
@philipl there is no "-hwaccel nvdec", even for Windows (run ffmpeg.exe -hwaccels). "444 subsampling" - not subsampling, profile. Video subsampling is yuv420p. As I already wrote "cuvid supports lossless H.264 and also I can decode High 4:4:4 Predictive@L5 video with 2560x1090"
comment:8 by , 7 years ago
nvdec is an alias for cuda which is distinct from cuvid.
I know that your sample is 420 and I know that it decodes - like I said, I tried it.
comment:9 by , 7 years ago
@philipl, Oh, yes - another bug found (ffmpeg for Windows x86_64),
ffmpeg.exe -hwaccel cuda -hwaccel_output_format cuda -i D:\sample.mkv -c:v h264_nvenc -b:v 5000k test.mp4
Leads to
[h264_nvenc @ 000001f2d7a86b40] Driver does not support the required nvenc API version. Required: 9.0 Found: 8.1 [h264_nvenc @ 000001f2d7a86b40] The minimum required Nvidia driver for nvenc is 390.77 or newer 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
While my driver is 417.01. Error mesage is deprecated.
comment:10 by , 7 years ago
@philipl, after updating the driver I have no artifacts in encoded video. The problem is that it
is suitable for encoding, not decoding video, particularly for Linux.
comment:11 by , 7 years ago
If you want to use hwaccels for playback, you need to use a proper media player - ffplay doesn't implement this. As I said previously, I recommend mpv, which will give you full decode and playback acceleration with nvdec.
comment:12 by , 7 years ago
@philipl, but using mpv is workaround, not bug fixing. I can also play this file easily without mpv without accelerated h.264 decoder (software version only).
comment:13 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | new → closed |
If you want to complain to someone about the visual artefacts when using cuvid, you need to report it to nvidia - it's happening due to limitations in their decoder, not ffmpeg.
comment:14 by , 7 years ago
| Resolution: | invalid |
|---|---|
| Status: | closed → reopened |
"it's happening due to limitations in their decoder"
WHICH limitations, I'm interested? https://mega.nz/#!281hwQCJ!bYhQpCpwDqBDJauIBufUvwou6h_0jnKIAodT-NrijNA - this sample decodes good.
comment:15 by , 7 years ago
| Resolution: | → invalid |
|---|---|
| Status: | reopened → closed |
I don't know. They don't document what the decoder is capable, or not capable of. What I do know is that when you use nvdec, your first sample plays without artefacts, and when you use cuvid, there are artefacts. The difference between nvdec and cuvid is the use of the native ffmpeg decoder for nvdec and the nvidia decoder library for cuvid. Another known limitation is that cuvid won't correctly decode 10bit hdr hevc.



https://mega.nz/#!X58GkaQC!oVlbhy1vGYe61cmOJfkavz9dFIAEwklWNTrPYJOkqSw - sample