mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.09k stars 2.88k forks source link

Slow performance with hardware decoding using AMD GPU #5634

Closed hrzhu closed 4 years ago

hrzhu commented 6 years ago

My GPU is AMD RX 560. The file mpv has problem hardware decoding:

ffprobe '[VCB-S]Toaru Kagaku no Railgun II[NCOP1][2160p][120fps][BDRip][x264_flac].mkv'
Input #0, matroska,webm, from '[VCB-S]Toaru Kagaku no Railgun II[NCOP1][2160p][120fps][BDRip][x264_flac].mkv':
  Metadata:
    encoder         : libebml v1.3.0 + libmatroska v1.4.0
    creation_time   : 2013-08-17T12:21:34.000000Z
  Duration: 00:01:32.01, start: 0.000000, bitrate: 28232 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709, progressive), 3840x2160, SAR 1:1 DAR 16:9, 119.88 fps, 119.88 tbr, 1k tbn, 239.76 tbc (default)
    Stream #0:1(jpn): Audio: flac, 48000 Hz, stereo, s16 (default)

On Windows side I've tried latest x64 build by lachs0r and shinchiro. mpv drops lots of frames when playing the file. Same problem with both d3d11va and dxva2. Media player classic with Lav video decoder(d3d11va and dxva2) can play the file with almost no frame drops. It only drops a few frames at the very start of playing. I guess it's something with my GPU's power management strategy. I guess my gpu is capable to hardware decode this 4K120FPS video. GPU-Z reports 99+% GPU load when playing the file with MPC but only 0% or 1% when playing the file with mpv. mpv-git-windows-d3d11va-log

On Linux side I've tried mpv from mc3man ppa and my self-compiled mpv. mpv also drops lots of frames with both vaapi and vdpau. mpv-git-linux-vdpau mpv-git-linux-vaapi

Let me know if you need more info.

ghost commented 6 years ago

Sample file?

mc4man commented 6 years ago

Don't know anything regarding amd but looking at your mesa version maybe related to this https://github.com/mpv-player/mpv/issues/5601 If so on your linux install see if the Oibaf ppa helps ,if not or if things get more screwed can use ppa-purge (- or fresh install, no big loss atm

ghost commented 6 years ago

It uses hw decoding with d3d11 and vdpau, but he claims it doesn't work well on either.

laichiaheng commented 6 years ago

@hrzhu Do you have this problem with vaapi on Linux: #5627 ? I can't add any chroma upscaling algorithm better than bilinear or deband function with vaapi enabled, otherwise, there will be glitches on the image. My GPU is AMD RX460 It drops lots of frames when decoding the 1080p60fps wmv3 codec with vaapi and vaapi-copy, too.

hrzhu commented 6 years ago

Sample file uploaded https://0x0.st/saNg.mkv

aufkrawall commented 6 years ago

On Windows, try forcing maximum clocks with ClockBlocker. Power saving features on AMD are really broken these days, but at least on Linux situation likely will improve with 4.17 (at least that's the case with AMD's drm-next branch for me).

Video plays for me without issues with low quality settings. But why even care about a 120fps video?

ghost commented 6 years ago

https://0x0.st/saNg.mkv

Works fine here with nvidia and hwdec on Linux. Of course it drops a shit ton of files, because it's 120 fps and I'm playing on a 60 hz monitor, so that means every second frame is dropped. Possibly using --video-sync=display-sync will make frame dropping more accurate.

Anyway, blame yourself for downloading garbage. The sample is anime, but there is no 4K 120fps anime (all is 23.976, and most isn't even 1080p as I've been told). So this is upconverted bloated garbage, and you should blame yourself for downloading it.

hrzhu commented 6 years ago

ClockBlocker doesn't help me with it.

Why do I even care about a 120fps video? Yes, it's not a regular video I would watch. I know it's upconverted. I just use it to test my hardware's decoding capability. Since MPC/Lav can play the file, I think mpv is not fully utilizing my hardware here.

aufkrawall commented 6 years ago

I suppose even with display-resample, reported framedrops are expected when the display runs with <120Hz. The result looks smooth here despite of this. If it doesn't look smooth for you, lower quality settings.

Try non-crappy samples to test your hardware. On my RX 560, I can play 4k HEVC 10 bit 60fps HDR video without problems in mpv with zero copy d3d11va decoding.

ghost commented 6 years ago

Yes, the framedrop count is supposed to report any frames that were not displayed during playback.

hrzhu commented 6 years ago

It's not the frames that were not displayed. It doesn't look smooth for me at all when playing with mpv. On Windows, MPC/Lav/D3D11va uses slightly less CPU and much more GPU resources than mpv/D3D11VA, so I suspect mpv is not fully utilising my GPU here. And how do I make mpv use lower quality settings btw?

dnmTX commented 6 years ago

@wm4 --video-sync=display-sync Is that a new option(the "display-sync" part) cause i don't see it documented anywhere?

ghost commented 6 years ago

No, that's a typo.

aufkrawall commented 6 years ago

@hrzhu Not changing default settings apart from display-resample should be sufficient. MPC HC doesn't support native D3D11VA decoding. There is no evidence to think that mpv wasn't functioning properly.

hrzhu commented 6 years ago

One thing I didn't mention. There are image glitches when playing the file with mpv. It also happens on Intel UHD 620 with vaapi but more frequent on AMD GPU. This might be the reason make me feel it doesn't look smooth. vcb-s toaru kagaku no railgun ii ncop1 2160p 120fps bdrip x264_flac mkv-00 00 11 I don't have this glitch when using MPC/LAV.

@aufkrawall I'm using K-Lite Codec Pack on Windows. There is a D3D11VA option in Lav Video decoder settings.

sfan5 commented 6 years ago

@hrzhu This is a typical artifact when you use literal garbage ("SVP") for upscaling. The frame you showed exists inside the video file, you can check it yourself.

If you don't see this frame with MPC, then it is being dropped (did you configure it to do this?). This would also explain why MPC is magically able to do smooth 4k120fps playback, while mpv is not. bildschirmfoto_2018-03-13_20-31-11

Hrxn commented 6 years ago

@sfan5 Do you mind me asking about which program this is?

sfan5 commented 6 years ago

vsedit

hrzhu commented 6 years ago

I don't know why I don't see the artifacts with MPC/LAV. It's all default Lav setting. Statistics in MPC says 11002 frames drawn and 5 drops that is ~119fps for this 92 seconds video. mpv drops ~10K with RX560 and ~8K with Intel UHD 620

ghost commented 6 years ago

I don't see that glitch here either. Although with nvdec I sometimes see the strange chroma fuckup. Doesn't happen with vdpau.

ghost commented 6 years ago

Oh wait, the screenshot is not actually in the sample. What a waste of time.

hrzhu commented 6 years ago

https://0x0.st/saAQ.mkv Another sample containing that frame.

ghost commented 6 years ago

Yeah, there are even worse frames in that. SVP artifacts that happen with software decoding too.

Anyway, this sample plays smoothly too, with hwdec and no advanced GL rendering.

Artoriuz commented 6 years ago

I have a RX470 here, and it works fine on Windows. Both d3d11va and dxva2 are working as expected. I believe this machine is using fairly out of date drivers though, maybe AMD broke something in more recent versions.

aufkrawall commented 6 years ago

I'm with Adrenalin 18.3.2 and there are no issues with d3d11va. I can only recommend to use d3d11va-zero-copy=yes, it helps performance a lot with slower GPUs (at least AMD and Intel).

Jj0YzL5nvJ commented 6 years ago

I have a GPU MSI Radeon RX 560 AERO ITX 4G OC and a monitor ASUS VG248QE. My monitor is 144Hz capable and I can see the artifacts clear as day, at least in saAQ.mkv. In saNg.mkv is more difficult, but such can be seen at Misaka's nose.

xrandr

Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
DisplayPort-0 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 531mm x 299mm
   1920x1080     60.00 + 144.00*  119.98    99.93    84.90    50.00    59.94  
   1920x1080i    60.00    50.00    59.94  
   1680x1050     59.95  
   1280x1024     75.02    60.02  
   1440x900      59.89  
   1280x960      60.00  
   1280x800      59.81  
   1152x864      75.00  
   1280x720      60.00    50.00    59.94  
   1024x768      75.03    70.07    60.00  
   832x624       74.55  
   800x600       72.19    75.00    60.32    56.25  
   720x576       50.00  
   720x480       60.00    59.94  
   640x480       75.00    66.67    60.00    59.94  
   720x400       70.08  
HDMI-A-0 disconnected (normal left inverted right x axis y axis)
DVI-D-0 disconnected (normal left inverted right x axis y axis)

https://0x0.st/sQil.txt https://0x0.st/sQiU.txt

Additional configuration for the test: xrandr --output DisplayPort-0 --set TearFree on

GALLIUM_HUD="cpu0+cpu1+cpu2+cpu3+cpu4+cpu5,cpu+fps,primitives-generated+draw-calls+CS-thread-busy,samples-passed+ps-invocations,buffer-wait-time;GPU-load+GPU-shaders-busy+GPU-ta-busy+GPU-vgt-busy+GPU-sx-busy+GPU-wd-busy+GPU-sc-busy+GPU-pa-busy+GPU-db-busy+GPU-cp-busy+GPU-cb-busy,.drequested-VRAM+VRAM-usage+mapped-VRAM+GTT-usage+mapped-GTT"

https://0x0.st/sQiC.png https://0x0.st/sQ-r.png

My CPU is too old to render these samples without resorting to hardware acceleration T.T

Edit: PS. For some strange reason, at the first loop on saAQ.mkv it always drops frames... you can see that in the GALLIUM_HUD graphic (sQiC.png).

Akemi commented 4 years ago

stale issue.