From 830e2b3dd475e0fd5535b9a110831c0e3306f9a2 Mon Sep 17 00:00:00 2001 From: mattmcw Date: Wed, 27 Mar 2024 21:06:24 -0400 Subject: [PATCH] Work getting this deployable on raspbian buster (latest makes omxplayer a nightmare to install). --- common.sh | 16 +++++++++++++++- nginx-rtmp.conf | 21 +++++++++++++++++++++ setup_raspi.sh | 14 ++++++++++++++ tv.sh | 8 ++++++-- 4 files changed, 56 insertions(+), 3 deletions(-) create mode 100644 nginx-rtmp.conf create mode 100644 setup_raspi.sh diff --git a/common.sh b/common.sh index 84c9ca7..324c1cc 100644 --- a/common.sh +++ b/common.sh @@ -28,6 +28,10 @@ SetupHistory () { echo "${HISTORY_SETUP}" | sqlite3 "${HISTORY}" } +WipeHistory () { + rm -f "${HISTORY}" +} + SetupPlayback () { echo "${PLAYBACK_SETUP}" | sqlite3 "${PLAYBACK}" } @@ -36,10 +40,20 @@ WipePlayback () { rm -f "${PLAYBACK}" } +GetRandom () { + QUERY="SELECT video FROM playback ORDER BY RANDOM() LIMIT 1;" + sqlite3 "${HISTORY}" "${QUERY}" +} + +UpdateHistory () { + QUERY="INSERT INTO" +} + PDB () { sqlite3 "${PLAYBACK}" "${1}" } HDB () { sqlite3 "${HISTORY}" "${1}" -} \ No newline at end of file +} + diff --git a/nginx-rtmp.conf b/nginx-rtmp.conf new file mode 100644 index 0000000..767b0a6 --- /dev/null +++ b/nginx-rtmp.conf @@ -0,0 +1,21 @@ + +rtmp { + server { + listen 1935; + + application live { + # Enable livestreaming + live on; + + # Disable recording + record off; + + # Allow only this machine to play back the stream + allow play 127.0.0.1; + deny play all; + + # Start omxplayer and play the stream out over HDMI + #exec /home/pi/stream.sh $name; + } + } +} diff --git a/setup_raspi.sh b/setup_raspi.sh new file mode 100644 index 0000000..6998023 --- /dev/null +++ b/setup_raspi.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +################################################ +# +# Works with 2020-02-13-raspbian-buster-lite.zip +# +################################################ + +sudo apt update -y +sudo apt upgrade -y +sudo apt install -y git curl omxplayer nginx libnginx-mod-rtmp +sudo apt autoremove + +sudo cat ./nginx-rtmp.conf >> /etc/nginx/nginx.conf \ No newline at end of file diff --git a/tv.sh b/tv.sh index 7bdc477..707de4d 100644 --- a/tv.sh +++ b/tv.sh @@ -26,7 +26,6 @@ AllFiles () { echo "${fileList}" } - SetupHistory WipePlayback SetupPlayback @@ -37,11 +36,16 @@ while true; do files=$(AllFiles) fileCount=$(cat "${files}" | wc -l) playbackCount=$(PDB "SELECT COUNT(*) FROM playback") - if [ ${fileCount} -eq 0 ]; then echo "No files to play :(" break fi + if [ ${playbackCount} -eq 0 ]; then + WipeHistory + SetupHistory + continue + fi + break done