Skip to content

Instantly share code, notes, and snippets.

@wormyrocks
Last active September 2, 2020 16:33
Show Gist options
  • Save wormyrocks/e04e280be074c950195ba861feb70933 to your computer and use it in GitHub Desktop.
Save wormyrocks/e04e280be074c950195ba861feb70933 to your computer and use it in GitHub Desktop.
build a playlist of videos from a flash drive and play through it with certain settings
#!/bin/bash
#set -e
# discover connected displays
DISPLAYNUM=$(tvservice -l | tail -c 2)
MMAL_DISPLAY=$(expr $DISPLAYNUM + 1)
export DISPLAY=:$DISPLAYNUM
rm -f /tmp/auto_playlist.m3u
VLC_SETTINGS="--no-qt-privacy-ask --ignore-config --vout=mmal_vout --fullscreen --no-osd --aspect-ratio=3:4 --loop --global-key-prev=Left --global-key-next=Right --mmal-display=hdmi-$MMAL_DISPLAY"
FIND_SETTINGS=" -type f -name *.mp4 -or -name *.png -or -name *.mkv -or -name *.hevc -or -name *.h264 -or -name *.jpg"
# turn off glob expansion, so we don't have to worry about asterisks in the find keywords
set -f
# Crude way of finding media files by filename, stick them in a playlist
find /media/pi/ -maxdepth 2 $FIND_SETTINGS >> /tmp/auto_playlist.m3u
# Find media files in my own directory as well as on a connected USB drive
find $(pwd) -maxdepth 1 $FIND_SETTINGS >> /tmp/auto_playlist.m3u
# turn on glob expansion
set -f
# Only open VLC if any files were found
[[ -s /tmp/auto_playlist.m3u ]] && nvlc $VLC_SETTINGS /tmp/auto_playlist.m3u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment