#9095(avcodec:new): h264_qsv DECODER is corrupted after flush [WINDOWS]
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] -------------------------------------+------------------------------------- Reporter: teslan | Type: defect Status: new | Priority: important Component: avcodec | Version: git- Keywords: qsv, | master h264_qsv, flush, seek, | Blocked By: avcodec_flush_buffers, | avcodec_send_packet | Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Unlike any other h264 decoder, '''h264_qsv''' is corrupted during a standard seeking procedure - specifically after `avcodec_flush_buffers(ctx)` and/or `avcodec_send_packet(ctx, NULL)` is called. First, `avcodec_send_packet()` yields `AVERROR_BUG` a couple of times and then only `AVERROR_EINVAL` is being returned until I stop the decoding. Errors `Error initializing the MFX video decoder: undefined behavior (-16)` and `Unsupported pixel format.` are being logged in great quantity while still trying to decode. After flushing, no valid frames are returned from the decoder. '''Note that when none of these flush functions are called after a seek, the decoder continues to work without any logged errors (but annoying artifacts are present, as expected)''' Platforms tested: Intel Ivy Bridge (i7-3632QM) Intel Ice Lake (i5-1035G4) So this spans almost through all the generations How to reproduce: Despite the fact that I need this in my application, the defect demonstrates itself also in ffplay: {{{ % .\ffplay.exe -codec:v h264_qsv .\video-001.ts ffplay version 4.3.2-2021-02-02-full_build-www.gyan.dev Copyright (c) 2003-2021 the FFmpeg developers built with gcc 10.2.0 (Rev6, Built by MSYS2 project) configuration: --enable-gpl --enable-version3 --enable-shared --disable- w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-lzma --enable- libsnappy --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libdav1d --enable-libzvbi --enable-librav1e --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libvidstab --enable- libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libmfx --enable-libcdio --enable-libgme --enable- libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable- libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libilbc --enable-libgsm --enable- libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint libavutil 56. 51.100 / 56. 51.100 libavcodec 58. 91.100 / 58. 91.100 libavformat 58. 45.100 / 58. 45.100 libavdevice 58. 10.100 / 58. 10.100 libavfilter 7. 85.100 / 7. 85.100 libswscale 5. 7.100 / 5. 7.100 libswresample 3. 7.100 / 3. 7.100 libpostproc 55. 7.100 / 55. 7.100 Input #0, mpegts, from '.\video-001.ts':q= 0KB sq= 0B f=0/0 Duration: 00:39:14.28, start: 0.000000, bitrate: 2199 kb/s Program 1 Metadata: service_name : Service01 service_provider: FFmpeg Stream #0:0[0x100]: Video: h264 (Main) ([27][0][0][0] / 0x001B), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn, 120 tbc ......... PRESS RIGHT ARROW HERE (SEEK)............. [h264_qsv @ 00000211e46eb7c0] Error initializing the MFX video decoder: undefined behavior (-16) Last message repeated 3 times [h264_qsv @ 00000211e46eb7c0] Error initializing the MFX video decoder: undefined behavior (-16) Last message repeated 1 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. Last message repeated 8 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. 0B f=0/0 Last message repeated 11 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. 0B f=0/0 Last message repeated 11 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. 0B f=0/0 Last message repeated 15 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. 0B f=0/0 Last message repeated 15 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. 0B f=0/0 Last message repeated 14 times [h264_qsv @ 00000211e46eb7c0] Unsupported pixel format. 0B f=0/0 ......... UNTIL I STOP IT }}} -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] -------------------------------------+------------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: important | Component: avcodec Version: git-master | Resolution: Keywords: qsv, | Blocked By: h264_qsv, flush, seek, | avcodec_flush_buffers, | avcodec_send_packet | Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | -------------------------------------+------------------------------------- Comment (by teslan): The bug does not demonstrate itself on ffplay always - especially if the video is in some "proper" container. But it does with all the transport streams. Example video: [https://mega.nz/file/FMoUhSSJ#I4yQmQfEtJkXP057v8iHg3G7YKNkpbuEnbfJS0vQwzQ] -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:1> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Changes (by cehoyos): * keywords: qsv, h264_qsv, flush, seek, avcodec_flush_buffers, avcodec_send_packet => qsv * priority: important => normal -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:2> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by cehoyos): Please test current FFmpeg git head, the only version supported on this bug tracker. -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:3> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by teslan): Tested right now on 5c8d4c4 (BtbN build)- same behaviour. No relevant commit was pushed since. -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:4> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by teslan): Ok, So after another testing the decoder seems to be corrupted only after it is flushed (by one of these functions or both) and is then fed by a non-key frame. Now it makes sense that with a "proper" container this issue does not manifest itself. I worked around this by simply throwing away all non-key packets after a seek. '''The issue is not fixed. ffplay still crashes with qsv_h264 after a seek in .ts and the behaviour is not consistent with h264, h264_cuvid or h264 with any tested hwaccel (vaapi, vdpau, dxva2, d3d11va)''' -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:5> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by cehoyos): Replying to [comment:5 teslan]:
ffplay still crashes with qsv_h264 after a seek in .ts You originally did not report a crash and the console output you provided did not indicate a crash. Is there a crash?
-- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:6> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 0 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by teslan): I'm very sorry for blatant imprecision of my expression. The comment is edited - i meant a corruption of decoder to the level that it does not provide any output frame, not a crash. There is also another, quite interesting part: you basically can not flush it. Does not matter what you do after a seek - It will always output exactly two more frames from a previously decoded "chunk". Trying to gather residual frames immediately after a flush with `avcodec_receive_frame` does not help as it will output invalid frames (with negative pts) indefinitely - without any error. The residual frames are outputted only after fresh packets are fed to it. -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:7> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Changes (by wenbinCHEN): * cc: wenbin.chen@… (added) * reproduced: 0 => 1 Comment: Hi teslan I reproduced this error. I think the cause is that qsv decoder assume that after seek(), the first frame should be key frame. However this is not true when playing your video. I am working on it and try to submit a patch to fix this. Thanks for your submission. -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:8> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Changes (by wenbinCHEN): * Attachment "0001-libavcodec-qsvdec-skip-non-key-frame-after-seek- func.patch" added. -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by wenbinCHEN): you can try this patch. I already submit it to our internal review and if it is ok I will submit it to community. Thanks -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:9> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by wenbinCHEN): https://patchwork.ffmpeg.org/project/ffmpeg/patch/20210219050920.1730759-1-w... -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:10> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
#9095: h264_qsv DECODER is corrupted after flush [WINDOWS] ------------------------------------+----------------------------------- Reporter: teslan | Owner: Type: defect | Status: new Priority: normal | Component: avcodec Version: git-master | Resolution: Keywords: qsv | Blocked By: Blocking: | Reproduced by developer: 1 Analyzed by developer: 0 | ------------------------------------+----------------------------------- Comment (by teslan): Sorry for the late answer. Yes that works fine, thank You! -- Ticket URL: <https://trac.ffmpeg.org/ticket/9095#comment:11> FFmpeg <https://ffmpeg.org> FFmpeg issue tracker
participants (1)
-
FFmpeg