Plays folders of videos on a loop from boot, with a controller menu, per-video on/off, play settings, a logo boot splash and a nightly YouTube sync. Tested on a Raspberry Pi 4; x86 paths are untested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
6.0 KiB
Enrichment video player
Plays the videos in one folder of ~/enrichment_videos on an endless loop, full
screen, starting automatically when the Raspberry Pi boots. No desktop needed.
~/enrichment_videos/
birds/ clip1.mp4 clip2.mp4
fish/ reef.mkv
Using it
Press any button, or up or down, to open the menu over the video. Left and right do nothing until the menu is open, so a stray press can't change the video.
In the list of folders:
| Control | Action |
|---|---|
| D-pad or left stick | Move up and down |
| Right | Open the folder |
| A | Play the highlighted folder |
| B or Back | Close the menu |
Inside a folder:
| Control | Action |
|---|---|
| A | Play that exact video, then carry on through the folder |
| X | Turn the video on or off |
| Left or B | Back to the folders |
Anywhere in the menu, RB goes to the next video and LB jumps to a random spot. The menu stays open so you can press them again. Next wraps back to the first video after the last, and does nothing if only one video is on.
Videos that are off stay on the Pi but are skipped, and this is remembered after a reboot. Turning off the video that is playing moves on to the next one. The last video left on in a folder can't be turned off.
Play settings
Press Start, or choose Settings at the bottom of the list of folders. Up and down choose a setting, left and right change it, and B closes the window. Changes apply straight away and are remembered after a reboot.
| Setting | What it does |
|---|---|
| Shuffle play order | Plays the videos that are on in a random order. All |
| of them play once before any repeats, with a new | |
| order each time round. | |
| Max time per video | Moves to the next video after this long. A longer |
| video starts at a random spot that leaves the full | |
| time to play: 1 hour of a 9 hour video starts 0 to 8 | |
| hours in. A folder with one video jumps to a new | |
| spot instead of moving on. | |
| Start videos at a random spot | Begins each video somewhere new instead of the start |
| Volume | Sets the sound level, or mutes it |
Controller notes
Menus close themselves after 30 seconds. The X/D switch on a Logitech pad can be in either position. A USB keyboard also works: arrows, Enter, Esc, Space for on/off, N for next, R for a random spot and S for settings.
Behaviour
- On boot it plays the last picked folder, starting from a random video other than the one last on screen. If that folder is gone or has no videos, it picks another folder at random and remembers it.
- Videos play in name order;
clip2comes beforeclip10. - Folders with no videos are left out of the menu. Sub-folders are not searched.
- Add or remove videos at any time: changes take effect when the folder next loops back to its first video, and new folders appear next time the menu opens.
- Damaged videos are skipped. If mpv crashes or freezes, it is restarted.
- Sound goes to whichever HDMI port has the screen attached.
Videos play smoothest as H.264 or H.265 at up to 1080p. 1080p at 60fps H.264 has been measured with no dropped frames; much above that (such as 4K H.264) is too much for the Pi.
YouTube
List videos or playlists in ~/enrichment_videos/youtube.txt, one per line, with the
folder to put them in:
# Folder name | link
Birds and Squirrels | https://www.youtube.com/watch?v=MrSYP-cotdg
Fish | https://www.youtube.com/playlist?list=...
Every night around 3am the Pi downloads anything new, at low priority so playback is not disturbed. To start straight away:
sudo systemctl start --no-block enrichment-youtube-sync
sudo journalctl -u enrichment-youtube-sync -f # watch progress
Videos appear only once fully downloaded, an interrupted download resumes next time,
and it stops rather than filling the disk (5 GB is kept free). A video is downloaded
only once, so deleting one from its folder removes it for good. To get it back, delete
its line from ~/.local/state/enrichment_player/youtube_archive.txt. Removing a line
from youtube.txt stops future downloads but keeps the videos already on the Pi.
An 8-hour 1080p video is about 16 GB. Check that you have permission to download and show the videos you list.
Starting up
The Pi starts as soon as it has power and goes straight to the player. It shows the logo with its progress, and any problem in red. Both HDMI ports are forced on at 1080p, so playback starts even if the TV is off or slow to wake. The picture goes to whichever port a screen answers on, or the last one that did.
On a Raspberry Pi, undo this by restoring cmdline.txt.before-enrichment and
config.txt.before-enrichment in /boot/firmware. The SD card or drive can be read
on any computer if the Pi will not start.
Maintenance
./install.sh # install and enable at boot
sudo systemctl restart enrichment-player # restart
sudo systemctl stop enrichment-player # stop until next boot
journalctl -u enrichment-player -f # watch the log (needs sudo)
python3 -m unittest # run the tests
The chosen folder is stored in ~/.local/state/enrichment_player/last_folder, and
the videos that are off in disabled.json and the play settings in settings.json
beside it.