mpv-player / mpv

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

meson-vdec: poor playback of h264 #8884

Closed danboid closed 1 year ago

danboid commented 3 years ago

Important Information

Provide following Information:

X96 Air Q1000 Amlogic S905X3 based TV box.

0.33.1-dirty

Manjaro ARM unstable branch, kernel 5.12.1-1-MANJARO-ARM

manjaro arm unstable repo

KDE plasma wayland, which works better than GNOME wayland for mpv. Attempting to play this video with mpv under wayland GNOME crashed mpv.

mesa 21.1.1-1

https://youtu.be/r4lWJO35o00

Reproduction steps

I am trying to play this video:

https://drive.google.com/file/d/14z1Gd8zXbJ2XWvULvmWXeqLVRcgUHo2p/view?usp=sharing

Under Manjaro ARM unstable KDE wayland (what a mouthful!)

My mpv.conf looks like this:

msg-level=all=v
vo=gpu
gpu-context=wayland
drm-connector=HDMI-A-1
fs=yes
#hwdec=auto
hwdec=v4l2m2m-copy
hwdec-codecs=all

Expected behavior

Smooth hw accelerated fullscreen video playback using the meson vpu.

Actual behavior

Very jerky video playback, less than 1 fps with 100's of dropped frames. I have tried experimenting with the plasma compositor settings but they don't seem to make any notable difference to mpv.

Log file

$ mpv VID_20210512_180639.mp4
[cplayer] Waiting for scripts...
[osd/libass] libass API version: 0x1501000
[osd/libass] libass source: commit: 0.15.1-0-g5447214643eacef71776350e779adf4b6c07bb3b
[osd/libass] Shaper: FriBidi 1.0.10 (SIMPLE) HarfBuzz-ng 2.8.1 (COMPLEX)
[osd/libass] Setting up fonts...
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
[cplayer] Set property: shared-script-properties -> 1
[cplayer] Done loading scripts.
[cplayer] Running hook: ytdl_hook/on_load
[ytdl_hook] ytdl:// hook
[ytdl_hook] not a ytdl:// url
[ifo_dvdnav] Opening VID_20210512_180639.mp4
[bdmv/bluray] Opening VID_20210512_180639.mp4
[file] Opening VID_20210512_180639.mp4
[demux] Trying demuxers for level=normal.
[cplayer] Set property: shared-script-properties -> 1
[osd/libass] libass API version: 0x1501000
[osd/libass] libass source: commit: 0.15.1-0-g5447214643eacef71776350e779adf4b6c07bb3b
[osd/libass] Shaper: FriBidi 1.0.10 (SIMPLE) HarfBuzz-ng 2.8.1 (COMPLEX)
[osd/libass] Setting up fonts...
[lavf] Found 'mov,mp4,m4a,3gp,3g2,mj2' at score=100 size=2048.
[file] stream level seek from 131072 to 810264
[demux] Detected file format: mov,mp4,m4a,3gp,3g2,mj2 (libavformat)
[cplayer] Opening done: VID_20210512_180639.mp4
[osd/libass] Using font provider fontconfig
[osd/libass] Done.
[find_files] Loading external files in .
[cplayer] Running hook: ytdl_hook/on_preloaded
[lavf] select track 0
[lavf] select track 1
 (+) Video --vid=1 (*) (h264 3840x2160 30.000fps)
 (+) Audio --aid=1 --alang=eng (*) (aac 2ch 48000Hz)
[vo/gpu/opengl] Initializing GPU context 'wayland'
[vo/gpu/wayland] Registered for protocol wl_compositor
[vo/gpu/wayland] Registered for protocol xdg_wm_base
[vo/gpu/wayland] Registered for protocol zxdg_decoration_manager_v1
[vo/gpu/wayland] Registered for protocol wl_shm
[vo/gpu/wayland] Registered for protocol wl_seat
[vo/gpu/wayland] Registered for protocol wl_data_device_manager
[vo/gpu/wayland] Registered for protocol zwp_idle_inhibit_manager_v1
[vo/gpu/wayland] Registered for protocol wl_output
[vo/gpu/wayland] Compositor doesn't support the wp_presentation protocol!
[vo/gpu/wayland] Enabling server decorations
[vo/gpu/opengl] EGL_VERSION=1.4
[vo/gpu/opengl] EGL_VENDOR=Mesa Project
[vo/gpu/opengl] EGL_CLIENT_APIS=OpenGL OpenGL_ES
[vo/gpu/opengl] Trying to create Desktop OpenGL context.
[vo/gpu/wayland] GL_VERSION='3.1 (Core Profile) Mesa 21.1.1'
[vo/gpu/wayland] Detected desktop OpenGL 3.1.
[vo/gpu/wayland] GL_VENDOR='Panfrost'
[vo/gpu/wayland] GL_RENDERER='Mali G31 (Panfrost)'
[vo/gpu/wayland] GL_SHADING_LANGUAGE_VERSION='1.40'
[vo/gpu/wayland] Loaded extension GL_ARB_sync.
[vo/gpu/wayland] Loaded extension GL_ARB_get_program_binary.
[vo/gpu/wayland] Loaded extension GL_ARB_shader_storage_buffer_object.
[vo/gpu/wayland] Loaded extension GL_ARB_arrays_of_arrays.
[vo/gpu/wayland] Loaded extension GL_ARB_debug_output.
[vo/gpu] Testing FBO format rgba16f
[vo/gpu] Using FBO format rgba16f.
[vo/gpu] Disabling HDR peak computation (one or more of the following is not supported: compute shaders=0, SSBO=1).
[vo/gpu] No advanced processing required. Enabling dumb mode.
[vo/gpu/wayland] Registered output Goldstar Company Ltd HDMI-A-1-LG TV SSCR/16843009 (0x24):
[vo/gpu/wayland]        x: 0px, y: 0px
[vo/gpu/wayland]        w: 3840px (1600mm), h: 2160px (900mm)
[vo/gpu/wayland]        scale: 2
[vo/gpu/wayland]        Hz: 59.940000
[vo/gpu] Resize: 0x0
[vd] Container reported FPS: 30.000300
[vd] Codec list:
[vd]     h264 - H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
[vd]     h264_v4l2m2m (h264) - V4L2 mem2mem H.264 decoder wrapper
[vd] Opening decoder h264
[vd] Looking at hwdec h264_v4l2m2m-v4l2m2m-copy...
[vd] Trying hardware decoding via h264_v4l2m2m-v4l2m2m-copy.
[vd] Using underlying hw-decoder 'h264_v4l2m2m'
[ffmpeg/video] h264_v4l2m2m: Using device /dev/video0
[ffmpeg/video] h264_v4l2m2m: driver 'meson-vdec' on card 'Amlogic Video Decoder' in mplane mode
[ffmpeg/video] h264_v4l2m2m: requesting formats: output=H264 capture=NM12
[vd] Selected codec: h264 (H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10)
[vf] User filter list:
[vf]   (empty)
[ad] Codec list:
[ad]     aac - AAC (Advanced Audio Coding)
[ad]     aac_fixed (aac) - AAC (Advanced Audio Coding)
[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...
[af] [in] 48000Hz stereo 2ch floatp
[af] [userspeed] 48000Hz stereo 2ch floatp
[af] [userspeed] (disabled)
[af] [convert] 48000Hz stereo 2ch floatp
[file] stream level seek from 1221442 to 834600
[file] stream level seek from 965672 to 1221442
[ao] Trying audio driver 'pulse'
[file] stream level seek from 1635391 to 835102
[ao/pulse] requested format: 48000 Hz, stereo channels, floatp
[file] stream level seek from 966174 to 1635391
[ao/pulse] Library version: 14.2.0
[ao/pulse] Proto: 34
[ao/pulse] Server proto: 4294967295
[ao/pulse] Channel layouts:
[ao/pulse]  - #fl
[ao/pulse]  - #fr
[ao/pulse]  - #fc
[ao/pulse]  - #lfe
[ao/pulse]  - #bl
[ao/pulse]  - #br
[ao/pulse]  - #flc
[ao/pulse]  - #frc
[ao/pulse]  - #bc
[ao/pulse]  - #sl
[ao/pulse]  - #sr
[ao/pulse]  - #tc
[ao/pulse]  - #tfl
[ao/pulse]  - #tfc
[ao/pulse]  - #tfr
[ao/pulse]  - #tbl
[ao/pulse]  - #tbc
[ao/pulse]  - #tbr
[ao/pulse] result: stereo
[ao/pulse] device buffer: 6718 samples.
[ao/pulse] using soft-buffer of 9600 samples.
AO: [pulse] 48000Hz stereo 2ch float
[cplayer] AO: Description: PulseAudio audio output
[autoconvert] inserting resampler
[swresample] format change, reinitializing resampler
[swresample] 48000Hz stereo floatp -> 48000Hz stereo float
[af] [out] 48000Hz stereo 2ch float
Using hardware decoding (v4l2m2m-copy).
[vd] Decoder format: 3840x2160 [0:0] nv12 auto/auto/auto/auto/auto CL=unknown
[vd] Using container aspect ratio.
[vf] [in] 3840x2160 nv12 bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vf] [userdeint] 3840x2160 nv12 bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vf] [userdeint] (disabled)
[vf] [autorotate] 3840x2160 nv12 bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vf] [autorotate] (disabled)
[vf] [convert] 3840x2160 nv12 bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vf] [convert] (disabled)
[vf] [out] 3840x2160 nv12 bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
VO: [gpu] 3840x2160 nv12
[cplayer] VO: Description: Shader-based GPU Renderer
[vo/gpu] reconfig to 3840x2160 nv12 bt.709/bt.709/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264
[vo/gpu/wayland] Reconfiguring!
[vo/gpu] Resize: 3840x2160
[vo/gpu] Window size: 3840x2160 (Borders: l=0 t=0 r=0 b=0)
[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] Texture for plane 0: 3840x2160
[vo/gpu] Texture for plane 1: 1920x1080
[vo/gpu] Testing FBO format rgba16f
[vo/gpu] Using FBO format rgba16f.
[vo/gpu] No advanced processing required. Enabling dumb mode.
[vo/gpu/wayland] Handling resize on the egl side
[vo/gpu] Resize: 3840x2160
[vo/gpu] Window size: 3840x2160 (Borders: l=0 t=0 r=0 b=0)
[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] Reported display depth: 8
[vo/gpu/wayland] Surface entered output Goldstar Company Ltd HDMI-A-1-LG TV SSCR/16843009 (0x24), scale = 2
[vo/gpu/wayland] Given DND offer with mime type text/plain
[vo/gpu/wayland] Given DND offer with mime type text/plain;charset=utf-8
[cplayer] first video frame after restart shown
[vo/gpu] Assuming 59.940000 FPS for display sync.
[cplayer] Set property: shared-script-properties -> 1
[cplayer] audio ready
[cplayer] delaying audio start 0.012188 vs. 0.000000, diff=0.012188
[cplayer] playback restart complete @ 0.000000, audio=ready, video=playing
AV: 00:00:00 / 00:00:20 (0%) A-V:  0.000
[cplayer] starting audio playback
[ao/pulse] starting AO
[cplayer] Set property: shared-script-properties -> 1
AV: 00:00:00 / 00:00:20 (0%) A-V:  0.000
[vo/gpu/wayland] Enabling idle inhibitor
AV: 00:00:01 / 00:00:20 (6%) A-V:  0.456 Dropped: 31

Audio/Video desynchronisation detected! Possible reasons include too slow
hardware, temporary CPU spikes, broken drivers, and broken files. Audio
position will not match to the video (see A-V status field).

AV: 00:00:12 / 00:00:20 (63%) A-V:  6.026 Dropped: 333
[lavf] EOF reached.
AV: 00:00:13 / 00:00:20 (66%) A-V:  6.364 Dropped: 347
[af] filter input EOF
[af] filter output EOF
[cplayer] audio filter EOF
AV: 00:00:13 / 00:00:20 (66%) A-V:  6.364 Dropped: 347
[cplayer] audio draining
[cplayer] audio EOF reached
[ao/pulse] audio end or underrun
AV: 00:00:13 / 00:00:20 (66%) A-V:  0.000 Dropped: 348
[ao/pulse] audio end or underrun
AV: 00:00:19 / 00:00:20 (99%) A-V:  0.000 Dropped: 505
[vf] filter input EOF
[vf] filter output EOF
AV: 00:00:19 / 00:00:20 (99%) A-V:  0.000 Dropped: 506
[cplayer] EOF code: 1
[cplayer] finished playback, success (reason 0)

Exiting... (End of file)
[cplayer] Set property: shared-script-properties -> 1
[vo/gpu/wayland] Disabling the idle inhibitor
[vo/gpu/wayland] Deregistering output Goldstar Company Ltd HDMI-A-1-LG TV SSCR/16843009 (0x24)

Sample files

https://drive.google.com/file/d/14z1Gd8zXbJ2XWvULvmWXeqLVRcgUHo2p/view?usp=sharing

cyph84 commented 2 years ago

@chewitt Sorry was away from this project for a while.

After building the folowing: linux from https://github.com/chewitt/linux/commits/amlogic-5.18.y commit a3ec4a99978d ffmpeg from https://github.com/jc-kynesim/rpi-ffmpeg/commits/dev/4.4/rpi_import_1 commit 766f042678 mpv with commit 349e437466 and some hacks to fix a segfault

drmprime works:

[vo/gpu] reconfig to 720x480 [186:157] drm_prime[nv12] bt.601/bt.601-525/bt.1886/limited/display SP=1.000000 CL=mpeg2/4/h264

However trying to seek causes:

[ffmpeg/video] h264_v4l2m2m: V4L2 capture poll unexpected timeout: events=0x145
[ffmpeg/video] h264_v4l2m2m: Poll thinks src Q has space; none found
[ffmpeg/video] h264_v4l2m2m: V4L2 capture poll unexpected timeout: events=0x145
[ffmpeg/video] h264_v4l2m2m: Poll thinks src Q has space; none found

Any clues on where I might start debugging this?

When you say "good seeking" which player app are you using to test?