0

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

Besi
  • 22,579
  • 24
  • 131
  • 223
  • What is the size of the video in bytes on disk, please? – Mark Setchell Mar 21 '22 at 22:50
  • @MarkSetchell I did compress the video that it is now around 20MB. However, The transition needs to be very snappy so that the whole experience is one fluid transition. I guess I will somehow have to preload the video anyway which is essentially my question here. – Besi Mar 22 '22 at 10:08
  • I was going to suggest you try storing it on a RAM disk to see if it is any faster to load https://www.interelectronix.com/raspberry-pi-4-ram-disk.html – Mark Setchell Mar 22 '22 at 10:11
  • Ah I see how this could improve drastically speed up the loading time. Thanks for that remark. I'll give that a shot. – Besi Mar 22 '22 at 10:13

0 Answers0