在`fbi`和`omxplayer`之间快速调度
我有一个在 RaspberryPi Zero 上运行的脚本,它正在等待按下按钮,然后通过 HDMI 显示视频:
- 脚本正在等待并显示
waiting
图像 - 按下按钮并显示 <显示代码>loading-video 图像
- 一旦使用
omxplayer
加载视频,loading-video
图像就会被视频播放“覆盖”。 - 当视频结束时,
loading-video
图像会再显示 500 毫秒,然后 - 再次显示
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:
- Script is waiting and displaying an the
waiting
image - The button is pressed and a
loading-video
image is shown - As soon as the video is loaded using
omxplayer
theloading-video
image is "overwritten" with the video playback. - When the video is over the
loading-video
image is shown for another 500ms before - 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论