Opened 4 years ago

Closed 11 months ago

Last modified 11 months ago

#9608 closed defect (invalid)

AMD hardware decoding unnecessarily frozen playback for recoverable error

Reported by: teeedubb Owned by:
Priority: normal Component: avdevice
Version: unspecified Keywords: h264
Cc: MasterQuestionable Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: yes

Description (last modified by teeedubb)

Hi All,

I have been experiencing heavy artifacting in dvb-t live TV streams after corruption in videos with ffmpeg + vaapi + AMD polaris GPU (rx560). The video in question is a live TV stream and I am able to reproduce the issue when the recording is played from a local harddisk. The issue occurs in linux and windows, in kodi, vlc and ffplay and the videos recover OK when played on nvidia and intel gpu's on both windows and linux. The video plays ok if I disable vaapi (most of my testing is done in linux).

I have tried updating mesa to the current release, using a 5.15 kernel and tried various operating systems (manjaro, libreelec nighty, ubuntu 20.04, windows 10).

output of
ffmpeg -hwaccel vaapi -i Downloads/The\ Project.ts -vcodec rawvideo -acodec copy -f matroska -sn - | ffplay -report -i -
https://paste.ubuntu.com/p/tP9zrjZ796/

snippets of kodi.log from when the corruption occurs (I can provide more logs)
2021-11-30 20:36:36.863 T:333115 DEBUG <general>: ffmpeg[0x56321c011040X]: [mpegts] Packet corrupt (stream = , dts = 2007374635).
2021-11-30 20:52:18.128 T:366796 DEBUG <general>: ffmpeg[0x56321b9c1730X]: [mpegts] Packet corrupt (stream = , dts = 2209044203).
2021-11-30 20:52:33.301 T:372941 DEBUG <general>: ffmpeg[0x7f559c0dec80X]: [image2] Custom AVIOContext makes o sense and will be ignored with AVFMT_NOFILE format.

vainfo
http://ix.io/3EE0 <http://ix.io/3EE0>

mediainfo of a longer version of the sample video
https://paste.ubuntu.com/p/wthYZhVMMf/

video of artefacting
https://youtu.be/EJCfi4RP5Pg

Sample video (200mb) Corruption occurs at around 4m40s.
https://www.dropbox.com/s/aaiwgvsou10aq2w/corruption-recovery-amd.ts?dl=0
I have also uploaded the sample file "corruption-recovery-amd.ts" to the VLC file uploader.

I have also received confirmation from two people that they can reproduce the issue on their polaris hardware:

https://www.reddit.com/r/ffmpeg/comments/r66bns/any_rx560_or_amd_gpu_owners_out_there_that_can/htp8vil/
"I tried it out and got exactly what you're experiencing, I have a 2gb RX560. If I played the video through about 4:38 in VLC it would drop about 25 frames, and it wouldn't matter where I seeked the video to, it would be all garbled. Not only that, but my gpu utilization would go from about 10% while decoding to 50% once the frames dropped, spiking all over the place. I tried to play the video again, skipping over the corrupted frames, and there were no problems if I skipped over the bad part. I'm sure you're long past worrying about this by now, but I thought I'd pitch in anyway that the same thing happens for me. See screenshot. My CPU at 100% is because I am also transcoding video in the background on CPU."

and https://forums.whirlpool.net.au/thread/90x14jy4
"Can confirm the video desync and corruption issue using VLC with RX550 / Polaris12 – it looks like an issue decoding an I frame and the decoder never recovers so corrupt macroblocks appear

Playing the video with mpv + hardware acceleration has no issues

In Windows VLC with integrated Intel UHD graphics + DXVA2 acceleration, the playback temporarily freezes, skips some frames and then snaps back cleanly to the next I frame"

Thanks in advance.

Change History (7)

comment:1 by teeedubb, 4 years ago

Description: modified (diff)

comment:2 by teeedubb, 11 months ago

This issue is still present in LibreELEC-Generic.x86_64-13.0-nightly-20250403-8f555d3.img.
This uses KODI v22-alpha, which I believe uses FFmpeg v6.

comment:3 by nyanmisaka, 11 months ago

It looks like it's not an FFmpeg issue, but related to the Mesa Gallium VA-API driver, which is what AMD GPU uses but Intel and Nvidia GPU don't. I suggest reporting it at https://gitlab.freedesktop.org/mesa/mesa/-/issues and submitting a sample.

comment:4 by MasterQuestionable, 11 months ago

Analyzed by developer: set
Cc: MasterQuestionable added
Component: undeterminedavdevice
Keywords: h264 added
Summary: Ffmpeg + VAAPI on Polaris GPU not recovering after corrupt videoAMD hardware decoding unnecessarily frozen playback for recoverable error

͏    Looks like AMD hardware-specific bug.
͏    Hardware decoding hands off the handling to the hardware:
͏    In which case, there's not much that FFmpeg can help.

͏    Links gather:
͏    https://streams.videolan.org/ffmpeg/incoming/corruption-recovery-amd.ts (~ 195.32 MiB)
͏    https://old.reddit.com/r/ffmpeg/comments/r66bns/any_rx560_or_amd_gpu_owners_out_there_that_can/?sort=old#htp8vil
͏    https://forum.kodi.tv/showthread.php?tid=365209#pid_3073633
͏    .
͏    https://i.imgur.com/QEncVcl.png (~ 1.76 MiB; PNG: RGBA, 2559x1030)
[[
͏    AMD Radeon RX 560
͏    Windows 10
͏    Driver: 30.0.14011.3017 (2021-12-01)
]]

͏    "paste.ubuntu.com" requires login.
͏    And "ix.io" seems down.

͏    ----

͏    Alike AMD Radeon related failure:
͏    https://trac.ffmpeg.org/ticket/11260#comment:3
͏    (failed hardware encoding crashed the system outright)

Last edited 11 months ago by MasterQuestionable (previous) (diff)

comment:5 by teeedubb, 11 months ago

Thank you for the insights. I have posted this issue to https://gitlab.freedesktop.org/mesa/mesa/-/issues/12956

comment:6 by teeedubb, 11 months ago

Resolution: invalid
Status: newclosed

comment:7 by MasterQuestionable, 11 months ago

͏    You probably should link:
͏    https://trac.ffmpeg.org/ticket/9608#comment:4
͏    ; in the issue.

Note: See TracTickets for help on using tickets.