在`fbi`和`omxplayer`之间快速调度

发布于 2025-01-15 21:17:28 字数 1573 浏览 5 评论 0原文

我有一个在 RaspberryPi Zero 上运行的脚本,它正在等待按下按钮,然后通过 HDMI 显示视频:

  1. 脚本正在等待并显示 waiting 图像
  2. 按下按钮并显示 <显示代码>loading-video 图像
  3. 一旦使用omxplayer 加载视频,loading-video 图像就会被视频播放“覆盖”。
  4. 当视频结束时,loading-video 图像会再显示 500 毫秒,然后
  5. 再次显示waiting 图像。

加载视频需要几秒钟的时间,几乎无法使用。所以感觉这个应用程序非常慢,我正在寻找一个选项来A在另一个进程中预加载视频,然后以某种方式激活。 B 检测视频播放,以便我可以在后台切换到等待 图像。

也许 screen 可用于在暂停模式下预加载视频,但一旦 omxplayer 启动,它就会接管屏幕。我很高兴对此提供任何帮助。

这是我的代码(也在 github 上):

wait.py

from gpiozero import LED, Button
from signal import pause
import subprocess

button = Button(21)


subprocess.call(['sudo', 'bin/show_waiting.sh'])


def pressed():
    print("pressed")
    subprocess.call(['sudo', 'bin/show_loading.sh'])
    subprocess.call(['omxplayer', 'assets/video.mp4'])
    subprocess.call(['sudo', 'bin/show_waiting.sh'])

button.when_pressed = pressed

pause()

bin/show_loading.sh

killall -TERM fbi
fbi -T 1 assets/loading.jpg -a -noverbose

bin/show_waiting.sh

killall -TERM fbi
fbi -T 1 assets/waiting.jpg -a -noverbose

在此处输入图像描述

I have a script running on a RaspberryPi Zero, which is waiting for the press of a button to then display a video through HDMI:

  1. Script is waiting and displaying an the waiting image
  2. The button is pressed and a loading-video image is shown
  3. As soon as the video is loaded using omxplayer the loading-video image is "overwritten" with the video playback.
  4. When the video is over the loading-video image is shown for another 500ms before
  5. The waiting image is shown again.

Loading the video takes several seconds to the point where it's almost unusable. So feel of this application is quite slow and I'm looking for an option to A preload the video in another process that is then somehow activated.
B detect the video playback so I can in the background already switch to the waiting image.

Maybe screen could be used to preload the video in paused mode, but as soon as the omxplayer is started it takes over the screen. I'm very glad for any help on this.

Here is my code (also on github):

wait.py

from gpiozero import LED, Button
from signal import pause
import subprocess

button = Button(21)


subprocess.call(['sudo', 'bin/show_waiting.sh'])


def pressed():
    print("pressed")
    subprocess.call(['sudo', 'bin/show_loading.sh'])
    subprocess.call(['omxplayer', 'assets/video.mp4'])
    subprocess.call(['sudo', 'bin/show_waiting.sh'])

button.when_pressed = pressed

pause()

bin/show_loading.sh

killall -TERM fbi
fbi -T 1 assets/loading.jpg -a -noverbose

bin/show_waiting.sh

killall -TERM fbi
fbi -T 1 assets/waiting.jpg -a -noverbose

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文