comments on software installation
(So as you can see, I shirked the opportunity to learn Python (yet again), and just did it with a shell script. Results are a little janky, like you can see a text cursor blinking on top of the cover images, and it takes a little while to start playing a selected video, during which time you see a Linux text screen with login prompt, but overall this gets the job done reliably, it seems.)
The main script, called svp.sh, is located under /home/pi. It has to be run as root, unless you take some care to set up permissions and groups and stuff.
You also need to create the file /etc/systemd/system/svp.service as shown, and you'll need to add a line to /etc/fstab as indicated if you want to use a removeable USB stick for the video data, as I have done.
The script svp.sh requires the free software programs "fim" and "mpv". These permit images and videos to be displayed directly on the Linux framebuffer, i.e., the "text console", without needing to run X Windows.
Also, to read the state of the buttons (GPIO lines on the Pi), I had to install "gpiod", and as you can see, svp.sh uses the related utility, "gpioget". On the Orange Pi, the old and "deprecated" method of using sysfs (/sys/class/gpio/export, etc.) had been working fine, but when I switched to Raspberry Pi, this stopped working for reasons I could never figure out. And since they had scared me with that "deprecated" stuff, I decided to do it the new, "right" way, which is currently gpiod. Next year, probably something different. How come the "right" way doesn't actually come installed in the "approved" software image? No comment...
In order to make this video player come up automatically at startup without intervention, it needs to be installed as a systemd "service", with the "Restart" feature activated. (This is the "modern" Linux way, as opposed to /etc/init.d/.)
You'll need to do "systemctl enable svp.service" after adding the .service file to the proper systemd directory.
This setup assumes that you have a USB data stick on /dev/sda, formatted as ext2 (I don't recommend vfat because it has troubles with files over 4GB, which many video files are; maybe you know the way to make vfat use larger files, as it supposedly can do; but for me, the best and quickest solution was ext2). I mount the USB stick at /mnt. One directory named videos/ contains the videos of course, ending with extension ".mpg"; another directory called images/ contains the "thumbnail" (but full-size) cover images representing each video, same names as the video files except ending in extension ".jpg". If there is not a cover image for a given video file, a default file named "notfound.jpg" is displayed instead. (All this can be changed by editing svp.sh.)
I had to edit the VID_CMD line in svp.sh to set my audio to the right device, in order to get audio to come over the HDMI cable instead of the audio jack on the RPi3B. This meant adding an option of the form "--audio-device=...", but I haven't included the exact text here because it probably won't help and may hurt other users. If you don't get audio where you want it, try "mpv --audio-device=help" to see the available choices.
Comments
Post a Comment