husudosu / mpv-remote-node

MPV Remote plugin
MIT License
47 stars 8 forks source link

2nd play failure (update) #11

Open dream7180 opened 2 years ago

dream7180 commented 2 years ago

Archlinux as a HTPC and NAS server (no desktop): nodejs-18.7, npm-8.16, mpv-0.34.1, ffmpeg-5.0.1 (all official build) mpv-remote-node and app are up-to-date. I run mpv and mpv-remote-node as an system service (mpv.service as below):

[Unit] Description=MPV Media Player After=network-online.target

[Service] User=root Group=root Type=simple ExecStart=/usr/bin/mpv --idle ExecStartPost=/usr/bin/node /root/.config/mpv/scripts/mpvremote/remoteServer.js --expose-gc Environment=NODE_ENV=production Restart=on-failure RestartSec=6 RemainAfterExit=yes

[Install] WantedBy=multi-user.target

mpv-remote APP connection is OK, and play a video by the APP is OK. After the first play is stopped, I choose another (or just the same) video to play, it will fail. The APP connection is still OK, but unable to play unless I restart the mpv.service, problem repeated. It happened since the last issue I raised. It has noting to do with the uselocaldb. Now the service log changes, please take a look, I can not confirm whether mpv or mpv-remote or ffmpeg cause this bug.

This is log of the first play (successful) : 17:43 VO: [gpu] 1920x1080 vaapi[nv12] 17:43 AO: [alsa] 48000Hz stereo 2ch float 17:43 Using hardware decoding (vaapi). 17:43 Cannot load libcuda.so.1 17:43 [vo/gpu/vaapi-egl] failed to retrieve libavutil frame constraints 17:43 [ffmpeg] AVHWDeviceContext: Failed to query surface attributes: 20 (the requested function is not implemented). 17:43 [vo/gpu/opengl] Failed to set up VT switcher. Terminal switching will be unavailable. 17:43 [vo/gpu] Can't open TTY for VT control: No such device or address 17:43 error: XDG_RUNTIME_DIR is invalid or not set in the environment. 17:43 (+) Audio --aid=1 () (aac 2ch 44100Hz) 17:43 (+) Video --vid=1 () (h264 1920x1080 25.000fps) 17:43 [mpvremote] } 17:43 [mpvremote] flag: 'append-play' 17:43 [mpvremote] filename: '/nasd1/Video/MTV/SNH48/SNH48_1080p.mp4', 17:43 [mpvremote] {

This is log of the subsequent play (failure) : 18:42 [mpvremote] Entry added/updated 18:42 [mpvremote] Watchlisthandler called 18:42 [mpvremote] Mediastatus updated 18:42 Video: no video 18:42 Error opening/initializing the selected video_out (--vo) device. 18:42 [vo/gpu] Failed initializing any suitable GPU context! 18:42 error: XDG_RUNTIME_DIR is invalid or not set in the environment. 18:42 [vo/gpu/opengl] Failed to set CRTC for connector 95: Permission denied 18:42 [vo/gpu] Failed to commit ModeSetting atomic request (-13) 18:42 [vo/gpu/opengl] Failed to set up VT switcher. Terminal switching will be unavailable. 18:42 [vo/gpu] Can't open TTY for VT control: No such device or address 18:42 error: XDG_RUNTIME_DIR is invalid or not set in the environment. 18:42 Subs --sid=2 'TC' (ass) 18:42 (+) Subs --sid=1 () 'SC' (ass) 18:42 (+) Audio --aid=3 --alang=chi (ac3 6ch 48000Hz) 18:42 Audio --aid=2 --alang=jpn (opus 7ch 48000Hz) 18:42 Audio --aid=1 --alang=jpn () (opus 2ch 48000Hz) 18:42 (+) Video --vid=1 (*) (hevc 1920x1036 23.976fps) 18:42 Playing: /nasd1/Video/Movie/动画/千と千尋の神隠し Spirited Away [BD 1920x1036 HEVC-10bit OPUSx2 AC3]/千と千尋の神隠し Spirited Away [BD 1920x1036 HEVC-10bit OPUSx2 AC3.mkv 18:42 [mpvremote] } 18:42 [mpvremote] flag: 'append-play' 18:42 [mpvremote] filename: '/nasd1/Video/Movie/动画/千と千尋の神隠し Spirited Away [BD 1920x1036 HEVC-10bit OPUSx2 AC3]/千と千尋の神隠し Spirited Away [BD 1920x1036 HEVC-10bit OPUSx2 AC3.mkv', 18:42 [mpvremote] {

husudosu commented 2 years ago

Interesting MPV-remote should not affect your decoding settings. The remote server mainpulates only the HTTP Header fields when opening stream from other apps for example Aniyomi.

18:42
Video: no video
18:42
Error opening/initializing the selected video_out (--vo) device.
18:42
[vo/gpu] Failed initializing any suitable GPU context!
18:42
error: XDG_RUNTIME_DIR is invalid or not set in the environment.
18:42
[vo/gpu/opengl] Failed to set CRTC for connector 95: Permission denied
18:42
[vo/gpu] Failed to commit ModeSetting atomic request (-13)
18:42

These lines look suspicious for me. It seems by some reason MPV cannot get Video device and XDG_RUNTIME_DIR has been not set. Maybe try running MPV without the daemon.

BTW: I did a pull request on node-mpv, no response yet (it's been a month). For next release probably gonna replace node-mpv with my fork. Based on recent activity of project, seems it's not maintained anymore. I'll try to maintain it.

dream7180 commented 2 years ago

XDG_RUNTIME_DIR not set will not cause failure. problem is that 2nd playing can not load GPU decoding anymore. I think run mpv in idle mode is not an issue, and have to do this to keep connection for mpv-remote app. [vo/gpu] Failed to commit ModeSetting atomic request (-13) [vo/gpu/opengl] Failed to set CRTC for connector 95: Permission denied

dream7180 commented 2 years ago

If I disable GPU decoding (vo=drm in mpv.conf), then everything will be OK. But this is not what I want for it will cause high CPU occupation.