我正在 Windows 10 上的 Debian 环境中编写一个小程序。我打算稍后在我的 Raspberry Pi 4 上使用此代码。
该代码在一天中的特定时间通过 VLC 运行视频。
VLC代码(Python3)的核心如下。底部有完整的 Python 代码。
VLC 代码:
import vlc;
Instance = vlc.Instance('--fullscreen');
player = Instance.media_player_new();
Media = Instance.media_new("../videos/starscape.mp4");
Media.get_mrl();
player.set_media(Media);
player.play();
但是,这会引发各种错误。
VLC media player 3.0.7 Vetinari (revision 3.0.7-0-g86cee31099)
shared memfd open() failed: Function not implemented
[00007fffdc1e0410] vlcpulse audio output error: PulseAudio server connection failure: Connection refused
shared memfd open() failed: Function not implemented
[00007fffdc225830] dbus interface error: Failed to connect to the D-Bus session daemon: Unable to autolaunch a dbus-daemon without a $DISPLAY for X11
[00007fffdc225830] main interface error: no suitable interface module
[00007fffdc1291a0] main libvlc error: interface "dbus,none" initialization failed
[00007fffdc204440] main interface error: no suitable interface module
[00007fffdc1291a0] main libvlc error: interface "globalhotkeys,none" initialization failed
[00007fffdc1291a0] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.
error: XDG_RUNTIME_DIR not set in the environment.
[00007fffdc204440] skins2 interface error: cannot initialize OSFactory
这是我试图解决的问题:
- apt-get 更新和 apt-get 升级
- 卸载并重新安装vlc
- 卸载并重新安装 python-vlc
- 卸载并重新安装pulseaudio
- 谷歌这些错误并尝试随机解决方案
我以前从未在 CLI 中使用过 VLC,所以我不知道这是否是我的代码、我的安装或 Debian 实例的错误。
谁能指出我正确的方法?
完整代码(仍在 WIP,但总体思路已经存在)要点:https ://gist.github.com/Code2Empower/7deb6e05ffd10b0ea83eaff41c8cf294