在Raspberry Pi上设置使用VLC循环视频的systemd服务



我有一个Raspberry Pi 4,我正在一个展示柜里使用它来循环播放一些mp4视频。虽然通常我可以简单地使用桌面GUI打开VLC,加载它们,点击播放并最大化到全屏,但我希望它更健壮,能够重新启动。此外,我会注意到,由于一个未诊断的原因,当我尝试时,上述情况导致了视频中断。

我所尝试的是按照这些说明进行操作,但我非常感谢您帮助我解决可能出现的问题:https://gist.github.com/anthonyray/bb6fd7363cd99204330f17c54513f293

My videokiosk.service file looks like this:
    [Unit]
Description=videokiosk
[Service]
User=kioskman
Environment="DISPLAY=:0"
ExecStart=/usr/bin/vlc -Rf pastels.mp4
WorkingDirectory=/home/sean/Videos
Restart=always
[Install]
WantedBy=multi-user.target

加载并尝试运行后的状态为:

● videokiosk.service - videokiosk
 Loaded: loaded (/etc/systemd/system/videokiosk.service; enabled; vendor preset: enabled)
 Active: failed (Result: start-limit-hit) since Fri 2022-07-22 10:47:52 EDT; 3min 56s ago
Process: 885 ExecStart=/usr/bin/vlc -Rf pastels.mp4 (code=exited, status=0/SUCCESS)
   Main PID: 885 (code=exited, status=0/SUCCESS)
        CPU: 430ms
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Scheduled restart job, restart counter is at 5.
Jul 22 10:47:52 raspberrypi systemd[1]: Stopped videokiosk.
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Start request repeated too quickly.
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Failed with result 'start-limit-hit'.
Jul 22 10:47:52 raspberrypi systemd[1]: Failed to start videokiosk.

期刊是这样的:

-- Journal begins at Mon 2022-04-04 08:44:56 EDT. --
Jul 22 10:47:52 raspberrypi vlc[885]: > Shutting down.
Jul 22 10:47:52 raspberrypi vlc[885]: [00486638] [cli] lua interface: Requested shutdown.
Jul 22 10:47:52 raspberrypi vlc[885]: [afc0d578] cache_read stream error: cannot pre fill buffer
Jul 22 10:47:52 raspberrypi vlc[885]: [afc0e188] mjpeg demux error: cannot peek
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Succeeded.
░░ Subject: Unit succeeded
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit videokiosk.service has successfully entered the 'dead' state.
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Scheduled restart job, restart counter is at 5.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ Automatic restarting of the unit videokiosk.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Jul 22 10:47:52 raspberrypi systemd[1]: Stopped videokiosk.
░░ Subject: A stop job for unit videokiosk.service has finished
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A stop job for unit videokiosk.service has finished.
░░ 
░░ The job identifier is 1446 and the job result is done.
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Start request repeated too quickly.
Jul 22 10:47:52 raspberrypi systemd[1]: videokiosk.service: Failed with result 'start-limit-hit'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ The unit videokiosk.service has entered the 'failed' state with result 'start-limit-hit'.
Jul 22 10:47:52 raspberrypi systemd[1]: Failed to start videokiosk.
░░ Subject: A start job for unit videokiosk.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░ 
░░ A start job for unit videokiosk.service has finished with a failure.
░░ 
░░ The job identifier is 1446 and the job result is failed.

感谢您抽出时间和思考。

以下是行之有效的方法:将WantedBy字段更改为graphical.target;向服务用户授予对保存视频的目录的许可。

感谢@MarkSetchell提出了正确的问题。

相关内容

  • 没有找到相关文章

最新更新