mpv-player / mpv

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

Failed to play in hardware decoding mode. #5755

Closed kirbyzhou closed 5 years ago

kirbyzhou commented 6 years ago

mpv version and platform

0.28.2 / macOS 10.13.4

If you're not using git master or the latest release, update. Releases are listed here: https://github.com/mpv-player/mpv/releases

Reproduction steps

Expected behavior

Playback with hardware decoding.

Actual behavior

Playback with CPU decoding, CPU usage is very high

image

Log file

kirbyzhou@Kirby-iMac27:MacOS $ ./mpv -v /Volumes/Drobo/Movies/_4K/LG_Colors-of-Journey-HDR.mp4 [cplayer] Command line options: '-v' '/Volumes/Drobo/Movies/_4K/LG_Colors-of-Journey-HDR.mp4' [cplayer] mpv 0.28.2 (C) 2000-2017 mpv/MPlayer/mplayer2 projects [cplayer] built on Sat Feb 17 13:54:24 CET 2018 [cplayer] ffmpeg library versions: [cplayer] libavutil 56.7.101 [cplayer] libavcodec 58.11.101 [cplayer] libavformat 58.9.100 [cplayer] libswscale 5.0.101 [cplayer] libavfilter 7.12.100 [cplayer] libswresample 3.0.101 [cplayer] ffmpeg version: git-2018-02-14-dc77e64 [cplayer] [cplayer] Configuration: waf configure --prefix=/Users/djinn/apps/homebrew/Cellar/mpv/0.28.2 --enable-zsh-comp --enable-libmpv-shared --enable-html-build --enable-lua --confdir=/Users/djinn/apps/homebrew/etc/mpv --datadir=/Users/djinn/apps/homebrew/Cellar/mpv/0.28.2/share/mpv --mandir=/Users/djinn/apps/homebrew/Cellar/mpv/0.28.2/share/man --docdir=/Users/djinn/apps/homebrew/Cellar/mpv/0.28.2/share/doc/mpv --zshdir=/Users/djinn/apps/homebrew/Cellar/mpv/0.28.2/share/zsh/site-functions --enable-javascript [cplayer] List of enabled features: 51deb apple-remote asm atomics bsd-fstatfs build-date cocoa coreaudio cplayer cplugins cuda-hwaccel debug-build drmprime encoding fchmod ffmpeg gl gl-cocoa glob glob-posix gnuc gpl iconv javascript jpeg lcms2 libaf libass libass-osd libav-any libavcodec libavdevice libdl libm libmpv-shared lua optimize osx-thread-name plain-gl posix posix-or-mingw posix-spawn posix-spawn-native pthreads stdatomic videotoolbox-gl videotoolbox-hwaccel zlib zsh-comp [osc] lua-settings/osc.conf not found. [osd/libass] Shaper: FriBidi 1.0.1 (SIMPLE) [osd/libass] Setting up fonts... [ytdl_hook] lua-settings/ytdl_hook.conf not found. [osd/libass] Using font provider coretext [osd/libass] Done. [stats] lua-settings/stats.conf not found. [cplayer] Playing: /Volumes/Drobo/Movies/_4K/LG_Colors-of-Journey-HDR.mp4 [cplayer] Running hook: ytdl_hook/on_load [file] Opening /Volumes/Drobo/Movies/_4K/LG_Colors-of-Journey-HDR.mp4 [demux] Trying demuxers for level=normal. [lavf] Found 'mpegts' at score=50 size=2048. [lavf] avformat_find_stream_info() finished after 0 bytes. [demux] Detected file format: mpegts (libavformat) [cplayer] Opening done: /Volumes/Drobo/Movies/_4K/LG_Colors-of-Journey-HDR.mp4 [find_files] Loading external files in /Volumes/Drobo/Movies/_4K/ [cplayer] Running hook: ytdl_hook/on_preloaded [lavf] select track 0 [lavf] select track 1 [cplayer] (+) Video --vid=1 (hevc 3840x2160 60.000fps) [cplayer] (+) Audio --aid=1 --alang=eng (aac 2ch 48000Hz) [vo/gpu] Probing for best GPU context. [vo/gpu/opengl] Initializing GPU context 'cocoa' [vo/gpu] GL_VERSION='4.1 ATI-1.66.31' [vo/gpu] Detected desktop OpenGL 4.1. [vo/gpu] GL_VENDOR='ATI Technologies Inc.' [vo/gpu] GL_RENDERER='AMD Radeon Pro 580 OpenGL Engine' [vo/gpu] GL_SHADING_LANGUAGE_VERSION='4.10' [vo/gpu] Loaded extension GL_APPLE_rgb_422. [vo/gpu] Testing FBO format rgba16 [vo/gpu] Using FBO format rgba16. [vo/gpu] No advanced processing required. Enabling dumb mode. [vo/gpu] Assuming 59.992864 FPS for display sync. [vd] Container reported FPS: 60.000000 [vd] Codec list: [vd] hevc - HEVC (High Efficiency Video Coding) [vd] Opening video decoder hevc [vd] Not trying to use hardware decoding: codec hevc is not on whitelist, or does not support hardware acceleration. [vd] Using software decoding. [vd] Detected 4 logical cores. [vd] Requesting 5 threads for decoding. [vd] Selected video codec: hevc (HEVC (High Efficiency Video Coding)) [ad] Codec list: [ad] aac - AAC (Advanced Audio Coding) [ad] aac_fixed (aac) - AAC (Advanced Audio Coding) [ad] aac_at (aac) - aac (AudioToolbox) [ad] Opening audio decoder aac [ad] Requesting 1 threads for decoding. [ad] Selected audio codec: aac (AAC (Advanced Audio Coding)) [cplayer] Starting playback... [af] Audio filter chain: [af] [in] 48000Hz stereo 2ch floatp [af] [out] 48000Hz stereo 2ch floatp [af] [ao] 48000Hz stereo 2ch floatp [ao] Trying audio driver 'coreaudio' [ao/coreaudio] requested format: 48000 Hz, stereo channels, floatp [ao/coreaudio] selected audio output device: Built-in Output (45) [ao/coreaudio] input channel layout: [ao/coreaudio] layout: tag: <0>, bitmap: <0>, descriptions <2> [ao/coreaudio] - description 0: label <4294967295, 64>, flags: <0>, coords: <0.000000, 0.000000, 0.000000> [ao/coreaudio] - description 1: label <4294967295, 64>, flags: <0>, coords: <0.000000, 0.000000, 0.000000> [ao/coreaudio] mp chmap: unknown2 [ao/coreaudio] input channel layout: [ao/coreaudio] layout: tag: <0>, bitmap: <0>, descriptions <2> [ao/coreaudio] - description 0: label <1, 0>, flags: <0>, coords: <0.000000, 0.000000, 0.000000> [ao/coreaudio] - description 1: label <2, 1>, flags: <0>, coords: <0.000000, 0.000000, 0.000000> [ao/coreaudio] mp chmap: stereo [ao/coreaudio] Channel layouts: [ao/coreaudio] - stereo [ao/coreaudio] - mono [ao/coreaudio] result: stereo [ao/coreaudio] Latency property cntl: 7 frames [ao/coreaudio] Latency property zisf: 512 frames [ao/coreaudio] Latency property tfas: 93 frames

[ao/coreaudio] using soft-buffer of 9600 samples. [cplayer] AO: [coreaudio] 48000Hz stereo 2ch floatp [cplayer] AO: Description: CoreAudio AudioUnit [vd] Decoder format: 3840x2160 yuv420p10 bt.709/bt.2020/pq/limited SP=10.000000 CL=unknown (auto 0.000000/0.000000/0.000000) [vf] Video filter chain: [vf] [in] 3840x2160 yuv420p10 bt.709/bt.2020/pq/limited SP=10.000000 CL=mpeg2/4/h264 [vf] [out] 3840x2160 yuv420p10 bt.709/bt.2020/pq/limited SP=10.000000 CL=mpeg2/4/h264 [cplayer] VO: [gpu] 3840x2160 yuv420p10 [cplayer] VO: Description: Shader-based GPU Renderer [vo/gpu] Resize: 7680x4320 [vo/gpu] Window size: 7680x4320 [vo/gpu] Video source: 3840x2160 (1:1) [vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 7680x4320 [vo/gpu] Video scale: 2.000000/2.000000 [vo/gpu] OSD borders: l=0 t=0 r=0 b=0 [vo/gpu] Video borders: l=0 t=0 r=0 b=0 [vo/gpu] Testing FBO format rgba16 [vo/gpu] Using FBO format rgba16. [vo/gpu] No advanced processing required. Enabling dumb mode. [vo/gpu] Texture for plane 0: 3840x2160 [vo/gpu] Texture for plane 1: 1920x1080 [vo/gpu] Texture for plane 2: 1920x1080 [vo/gpu] Resize: 7680x4320 [vo/gpu] Window size: 7680x4320 [vo/gpu] Video source: 3840x2160 (1:1) [vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 7680x4320 [vo/gpu] Video scale: 2.000000/2.000000 [vo/gpu] OSD borders: l=0 t=0 r=0 b=0 [vo/gpu] Video borders: l=0 t=0 r=0 b=0 [osd/libass] fontselect: (sans-serif, 400, 0) -> /System/Library/Fonts/Helvetica.ttc, -1, Helvetica [cplayer] first video frame after restart shown [cplayer] starting audio playback [cplayer] playback restart complete [statusline] AV: 00:00:00 / 00:01:41 (0%) A-V: -0.000 [vo/gpu] Resize: 7680x4320 [vo/gpu] Window size: 7680x4320 [vo/gpu] Video source: 3840x2160 (1:1) [vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 7680x4320 [vo/gpu] Video scale: 2.000000/2.000000 [vo/gpu] OSD borders: l=0 t=0 r=0 b=0 [vo/gpu] Video borders: l=0 t=0 r=0 b=0 [statusline] AV: 00:00:01 / 00:01:41 (1%) A-V: 0.000 Dropped: 26 [osd/libass] fontselect: (mpv-osd-symbols, 400, 0) -> mpv-osd-symbols-Regular, 0, mpv-osd-symbols-Regular [vo/gpu] Reallocating OSD texture to 8192x1024. [statusline] AV: 00:00:04 / 00:01:41 (4%) A-V: 0.000 Dropped: 92 [cplayer] Set property: window-scale=0.500000 -> 1 [vo/gpu] Resize: 3840x2160 [vo/gpu] Window size: 3840x2160 [vo/gpu] Video source: 3840x2160 (1:1) [vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 3840x2160 [vo/gpu] Video scale: 1.000000/1.000000 [vo/gpu] OSD borders: l=0 t=0 r=0 b=0 [vo/gpu] Video borders: l=0 t=0 r=0 b=0 [vo/gpu] Resize: 3840x2160 [vo/gpu] Window size: 3840x2160 [vo/gpu] Video source: 3840x2160 (1:1) [vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 3840x2160 [vo/gpu] Video scale: 1.000000/1.000000 [vo/gpu] OSD borders: l=0 t=0 r=0 b=0 [vo/gpu] Video borders: l=0 t=0 r=0 b=0 [vo/gpu] Resize: 3840x2160 [vo/gpu] Window size: 3840x2160 [vo/gpu] Video source: 3840x2160 (1:1) [vo/gpu] Video display: (0, 0) 3840x2160 -> (0, 0) 3840x2160 [vo/gpu] Video scale: 1.000000/1.000000 [vo/gpu] OSD borders: l=0 t=0 r=0 b=0 [vo/gpu] Video borders: l=0 t=0 r=0 b=0 [statusline] AV: 00:00:04 / 00:01:41 (5%) A-V: 0.164 Dropped: 93 [osd/libass] Shaper: FriBidi 1.0.1 (SIMPLE) [osd/libass] Setting up fonts... [osd/libass] Using font provider coretext [osd/libass] Done. [osd/libass] fontselect: (sans-serif, 400, 0) -> /System/Library/Fonts/Helvetica.ttc, -1, Helvetica [vo/gpu] Reallocating OSD texture to 2048x512. [statusline] AV: 00:00:06 / 00:01:41 (6%) A-V: 0.008 Dropped: 159 [cplayer] EOF code: 6
[ad] Uninit audio decoder. [vd] Uninit video. [cplayer] finished playback, success (reason 3) [cplayer] [cplayer] [cplayer] Exiting... (Quit) [osx] Exiting... [ytdl_hook] Exiting... [stats] Exiting... [osc] Exiting...

Sample files

http://demo-uhd3d.com/files/uhd4k/LG_Colors-of-Journey-HDR.mp4 [download by xunlei] or ed2k://|file|LG_Colors-of-Journey-HDR.mp4|498852548|b0eb94aaf2eb63bcd830df7ad519be34|h=wlsjogtccj6uwa42br5j4iesz5rc2gm7|/ [download by eMule]

Akemi commented 6 years ago

[vd] Not trying to use hardware decoding: codec hevc is not on whitelist, or does not support hardware acceleration.

you even marked the problem in the log yourself apparently. so a short search in the manual could have helped you with that at least. try with --hwdec-codecs=hevc, by default only h264,vc1,wmv3,hevc,mpeg2video,vp9 are whitelisted. if that doesn't work post a log again, but pls use a pasteboard site like https://0x0.st/.

Akemi commented 6 years ago

i misread the default value, sry. maybe @tmm1 knows why. i am not even sure which hardware supports hevc decoding in the first place.

[edit] according to this pdf (HEVC Movie Decode Support - Minimum configurations) it's 6th gen intel for 8bit and 7th gen for 10bit. it's probably worth trying with quicktime and vlc and see if it works.

Akemi commented 6 years ago

k quicktime can't playback that file, probably doesn't like the container (it's a ts and not mp4). a better file for testing is probably this. it's at least plays back in quicktime with software decoding on my old macbook.

kirbyzhou commented 6 years ago

I can use VLC to play it with hardware decode.

VLC Version 3.0.1 Vetinari (Intel 64bit).

image

image

tmm1 commented 6 years ago

I was not able to download the test file.

Did you try --hwdec=videotoolbox --hwdec-codecs=hevc

Akemi commented 6 years ago

i re-uploaded the first ~50mb of the sample from the OP here.

tmm1 commented 6 years ago

Seems to use hevc hwdec here:

[vd] Codec list:
[vd]     hevc - HEVC (High Efficiency Video Coding)
[vd] Opening decoder hevc
[vd] Looking at hwdec hevc-videotoolbox...
[vd] Trying hardware decoding via hevc-videotoolbox.
[vd] Selected codec: hevc (HEVC (High Efficiency Video Coding))
[vf] User filter list:
[vf]   (empty)
[ad] Codec list:
[ad]     aac - AAC (Advanced Audio Coding)
[ad]     aac_fixed (aac) - AAC (Advanced Audio Coding)
[ad]     aac_at (aac) - aac (AudioToolbox)
[ad] Opening decoder aac
[ad] Requesting 1 threads for decoding.
[ad] Selected codec: aac (AAC (Advanced Audio Coding))
[af] User filter list:
[af]   (empty)
[cplayer] Starting playback...
[vd] Pixel formats supported by decoder: videotoolbox_vld yuv420p10le
[vd] Codec profile: Main 10 (0x2)
[vd] Requesting pixfmt 'videotoolbox_vld' from decoder.
Using hardware decoding (videotoolbox).
[vd] Decoder format: 3840x2160 videotoolbox[nv12] bt.709/bt.2020/pq/limited/auto SP=10.000000 CL=unknown (auto 0.000000/0.000000/0.000000)
[vf] [in] 3840x2160 videotoolbox[nv12] bt.709/bt.2020/pq/limited/display SP=10.000000 CL=mpeg2/4/h264
[vf] [userdeint] 3840x2160 videotoolbox[nv12] bt.709/bt.2020/pq/limited/display SP=10.000000 CL=mpeg2/4/h264
[vf] [autorotate] 3840x2160 videotoolbox[nv12] bt.709/bt.2020/pq/limited/display SP=10.000000 CL=mpeg2/4/h264
[vf] [convert] 3840x2160 videotoolbox[nv12] bt.709/bt.2020/pq/limited/display SP=10.000000 CL=mpeg2/4/h264
VO: [libmpv] 3840x2160 videotoolbox[nv12]

But I'm seeing some issues during playback.. every other frame is a blue frame, and log shows:

[libmpv_render/videotoolbox] Unsupported CVPixelBuffer format.
[libmpv_render] Initializing texture for hardware decoding failed.
tmm1 commented 6 years ago

If I revert ffmpeg/ffmpeg@63d875772d265a885808532889f094f80afaac7a (and ffmpeg/ffmpeg@4c0798578cab410b4ad9c27bc47b5e09c9a66aba) then it fixes the playback issues.

/cc @rcombs

kirbyzhou commented 6 years ago

@tmm1 Which version of MPV did you take? I can not play it with hwdec.

[cplayer] Command line options: '--hwdec=videotoolbox' '--hwdec-codecs=hevc' '-v' '/Volumes/Drobo/Movies/_4K/LG_Colors-of-Journey-HDR.mp4' [cplayer] mpv 0.28.2 (C) 2000-2017 mpv/MPlayer/mplayer2 projects ... [ffmpeg/video] hevc: Could not find ref with POC 0 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [ffmpeg/video] hevc: Could not find ref with POC 5 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [vd] Falling back to software decoding. [vd] Detected 4 logical cores. [vd] Requesting 5 threads for decoding. [vd] Using software decoding. [vd] Decoder format: 3840x2160 yuv420p10 bt.709/bt.2020/pq/limited SP=10.000000 CL=unknown (auto 0.000000/0.000000/0.000000)

kirbyzhou commented 6 years ago

Oh, I can play it with hardware at very beginning without seek. If I seek to anytime, "[ffmpeg/video] hevc: Could not find ref with POC" happens, and fallback to software.

Akemi commented 6 years ago

maybe #5741 is also related to this.

tmm1 commented 6 years ago

fallback to software.

You can use --vd-lavc-software-fallback=no

kirbyzhou commented 6 years ago

With --vd-lavc-software-fallback=no

[cplayer] using demuxer frame duration for last frame [lavf] queuing seek to 2.319763 [lavf] execute seek (to 3.719763 flags 32) [ffmpeg] NULL: missing picture in access unit [lavf] seek done [cplayer] hr-seek, skipping to 2.319763 [statusline] AV: 00:00:02 / 00:00:10 (23%) A-V: 0.000 [ffmpeg/video] hevc: Could not find ref with POC 648 [ffmpeg/video] hevc: Could not find ref with POC 646 [ffmpeg/video] hevc: Could not find ref with POC 643 [ffmpeg/video] hevc: Could not find ref with POC 641 [ffmpeg/video] hevc: Could not find ref with POC 653 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [ffmpeg/video] hevc: Could not find ref with POC 651 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [statusline] AV: 00:00:02 / 00:00:10 (24%) A-V: 0.000 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [statusline] AV: 00:00:02 / 00:00:10 (24%) A-V: 0.000 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [statusline] (...) AV: 00:00:02 / 00:00:10 (24%) A-V: 0.000 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame! [statusline] (...) AV: 00:00:02 / 00:00:10 (24%) A-V: 0.000 [ffmpeg/video] hevc: Could not find ref with POC 658 [ffmpeg/video] hevc: hardware accelerator failed to decode picture [vd] Error while decoding frame!

tmm1 commented 6 years ago

Please try building ffmpeg master with this commit: https://github.com/tmm1/FFmpeg/commit/d5624b0401b6d65de9cdfd726f5c6e7a1496a494

Akemi commented 5 years ago

so i could test this myself now and the initial reported problem is fixed.

one problem still persists, the Could not find ref with POC X when seeking. though since this is a different issue and the seeking problem was already reported (#5893) i will close this.