1 year ago
#318864
Besi
Quickly dispatching between `fbi` and `omxplayer`
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
python
hdmi
raspberry-pi-zero
omxplayer
fbi
0 Answers
Your Answer