Compare commits
3 Commits
f909a90e33
...
1b8f2a8466
Author | SHA1 | Date |
---|---|---|
Matt McWilliams | 1b8f2a8466 | |
Matt McWilliams | 3484fb6c8f | |
Matt McWilliams | 830e2b3dd4 |
14
common.sh
14
common.sh
|
@ -28,6 +28,10 @@ SetupHistory () {
|
||||||
echo "${HISTORY_SETUP}" | sqlite3 "${HISTORY}"
|
echo "${HISTORY_SETUP}" | sqlite3 "${HISTORY}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WipeHistory () {
|
||||||
|
rm -f "${HISTORY}"
|
||||||
|
}
|
||||||
|
|
||||||
SetupPlayback () {
|
SetupPlayback () {
|
||||||
echo "${PLAYBACK_SETUP}" | sqlite3 "${PLAYBACK}"
|
echo "${PLAYBACK_SETUP}" | sqlite3 "${PLAYBACK}"
|
||||||
}
|
}
|
||||||
|
@ -36,6 +40,15 @@ WipePlayback () {
|
||||||
rm -f "${PLAYBACK}"
|
rm -f "${PLAYBACK}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GetRandom () {
|
||||||
|
QUERY="SELECT video FROM playback ORDER BY RANDOM() LIMIT 1;"
|
||||||
|
sqlite3 "${HISTORY}" "${QUERY}"
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateHistory () {
|
||||||
|
QUERY="INSERT INTO"
|
||||||
|
}
|
||||||
|
|
||||||
PDB () {
|
PDB () {
|
||||||
sqlite3 "${PLAYBACK}" "${1}"
|
sqlite3 "${PLAYBACK}" "${1}"
|
||||||
}
|
}
|
||||||
|
@ -43,3 +56,4 @@ PDB () {
|
||||||
HDB () {
|
HDB () {
|
||||||
sqlite3 "${HISTORY}" "${1}"
|
sqlite3 "${HISTORY}" "${1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
encode.sh
23
encode.sh
|
@ -11,21 +11,34 @@ if [ ${count} == 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
SCALE="scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2"
|
SCALE="-filter_complex scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2"
|
||||||
|
HWENCODE="-hwaccel auto"
|
||||||
|
SILENT="-loglevel quiet -stats"
|
||||||
|
|
||||||
|
if [[ "${BUG}" != "" ]]; then
|
||||||
|
SCALE="-i ${BUG} -filter_complex [0]scale=${WIDTH}:${HEIGHT}:force_original_aspect_ratio=decrease,pad=${WIDTH}:${HEIGHT}:(ow-iw)/2:(oh-ih)/2,overlay=x=0:y=0[out] -map [out]"
|
||||||
|
fi
|
||||||
|
|
||||||
Encode () {
|
Encode () {
|
||||||
name=$(basename "${1}")
|
name=$(basename "${1}")
|
||||||
nameNoExt=${name%.*}
|
nameNoExt=${name%.*}
|
||||||
now=$(date '+%s')
|
now=$(date '+%s')
|
||||||
output="${VIDEOS}/${nameNoExt}_${now}.flv"
|
output="${VIDEOS}/${nameNoExt}_${now}.mkv"
|
||||||
if [ -f "${VIDEOS}/${nameNoExt}"*".flv" ]; then
|
#echo $output
|
||||||
|
if [ -f "${VIDEOS}/${nameNoExt}"*".mkv" ]; then
|
||||||
echo "File ${name} already exists"
|
echo "File ${name} already exists"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
echo "Encoding ${name}..."
|
echo "Encoding ${name}..."
|
||||||
ffmpeg -i "${1}" -c:v libx264 -tune zerolatency -pix_fmt yuv420p -vf "${SCALE}" \
|
if [[ "${name}" == *".jpg" ]] || [[ "${name}" == *".jpeg" ]] || [[ "${name}" == *".png" ]]; then
|
||||||
|
ffmpeg -nostdin -loop 1 -t 30 -i "${1}" ${SCALE} -c:v libx264 -tune zerolatency -pix_fmt yuv420p -r 30 -t 30 \
|
||||||
|
-an ${SILENT} \
|
||||||
|
"${output}"
|
||||||
|
else
|
||||||
|
ffmpeg -nostdin ${HWENCODE} -i "${1}" ${SCALE} -c:v libx264 -tune zerolatency -pix_fmt yuv420p \
|
||||||
-c:a aac -b:a 190k -ac 2 -ar 44100 \
|
-c:a aac -b:a 190k -ac 2 -ar 44100 \
|
||||||
-f flv "${output}"
|
-f flv ${SILENT} "${output}"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
fileList=$(mktemp)
|
fileList=$(mktemp)
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source ./common.sh
|
||||||
|
|
||||||
|
fileList=$(mktemp)
|
||||||
|
shuffleList=$(mktemp)
|
||||||
|
|
||||||
|
ls -1 "${VIDEOS}/" > "${fileList}"
|
||||||
|
rm -rf playlist.txt
|
||||||
|
|
||||||
|
count=10
|
||||||
|
for i in $(seq $count); do
|
||||||
|
cat "${fileList}" | shuf > "${shuffleList}"
|
||||||
|
while read videoIn; do
|
||||||
|
echo "file '${VIDEOS}/${videoIn}'" >> playlist.txt
|
||||||
|
done < "${shuffleList}"
|
||||||
|
done
|
||||||
|
|
||||||
|
rm -f "${fileList}"
|
||||||
|
rm -f "${shuffleList}"
|
|
@ -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
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
source ./common.sh
|
||||||
|
|
||||||
|
ffmpeg -re -f concat -safe 0 -stream_loop -1 -i playlist.txt -c copy -f flv "${DESTINATION}"
|
8
tv.sh
8
tv.sh
|
@ -26,7 +26,6 @@ AllFiles () {
|
||||||
echo "${fileList}"
|
echo "${fileList}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SetupHistory
|
SetupHistory
|
||||||
WipePlayback
|
WipePlayback
|
||||||
SetupPlayback
|
SetupPlayback
|
||||||
|
@ -37,11 +36,16 @@ while true; do
|
||||||
files=$(AllFiles)
|
files=$(AllFiles)
|
||||||
fileCount=$(cat "${files}" | wc -l)
|
fileCount=$(cat "${files}" | wc -l)
|
||||||
playbackCount=$(PDB "SELECT COUNT(*) FROM playback")
|
playbackCount=$(PDB "SELECT COUNT(*) FROM playback")
|
||||||
|
|
||||||
if [ ${fileCount} -eq 0 ]; then
|
if [ ${fileCount} -eq 0 ]; then
|
||||||
echo "No files to play :("
|
echo "No files to play :("
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
if [ ${playbackCount} -eq 0 ]; then
|
||||||
|
WipeHistory
|
||||||
|
SetupHistory
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue