Introduction
Introduction Statistics Contact Development Disclaimer Help
tSeveral bugfixes - bitreich-tv - meme tv encoding and streaming
git clone git://src.adamsgaard.dk/bitreich-tv
Log
Files
Refs
---
commit 9955fec4d21435eae1aa98c8c7078932d192df5c
parent 3a8559a5c96734befbfdb580c7e8a2ab491ea6d4
Author: Anders Damsgaard <[email protected]>
Date: Tue, 11 Aug 2020 21:26:32 +0200
Several bugfixes
Diffstat:
M brtv-start.sh | 51 ++++++++++++++++++++---------…
1 file changed, 33 insertions(+), 18 deletions(-)
---
diff --git a/brtv-start.sh b/brtv-start.sh
t@@ -1,12 +1,6 @@
#!/bin/sh
-# generate title animations and start streaming server
-
-pass="$(gpg2 -q -d icecastpass.gpg)"
-
-if [ $# -ne 1 ]; then
- printf 'usage: %s <memecache_path>\n' "$0" >&2
- exit
-fi
+# generate title animations and start streaming to server
+# requirements: ffmpeg(1), convert(1)
### CONFIGURATION START
t@@ -44,6 +38,20 @@ title_display_time=5
### CONFIGURATION END
+pass="$(gpg2 -q -d icecastpass.gpg)"
+
+die() {
+ printf '%s: error: %s\n' "${0##*/}" "$1" >&2
+ exit 1
+}
+
+regeximatch() {
+ printf '%s' "$1" | grep -iEq "$2"
+}
+
+if [ $# -ne 1 ]; then
+ die "usage: ${0##*/} <memecache_path>"
+fi
fit_img_16_9() {
convert -resize "$video_resolution"\> -size "$video_resolution" "$1" \
t@@ -62,6 +70,7 @@ video_from_img() {
title_slide() {
img="$(basename "${1%.*}".png)"
+ #echo "title_slide $1 -> $img"
convert -size "$video_resolution" "xc:${bgcolor}" \
-pointsize 48 -fill "$fgcolor" \
-gravity center -draw "text 0,0 '#${img%.*}'" "$img"
t@@ -70,21 +79,28 @@ title_slide() {
-i anullsrc=r=48000 \
-i "$img" \
-t "${title_display_time}" \
- $ffmpec_codec \
+ $ffmpeg_codec \
"$2" && rm "$img"
}
video_conv() {
- ffmpeg -y -i "$1" $ffmpeg_codec -max_muxing_queue_size 1024 "$2"
+ printf 'encode %s -> %s\n' "$1" "$2"; ffmpeg -y -i "$1" $ffmpeg_codec …
}
mkdir -p "$title"
mkdir -p "$memecache_conv"
# generate video from each image
-for f in "$memecache"/*.{jpg,jpeg,JPG,png,PNG}; do
+for f in "$memecache"/*.jpg \
+ "$memecache"/*.jpeg \
+ "$memecache"/*.JPG \
+ "$memecache"/*.png \
+ "$memecache"/*.PNG; do
out="${memecache_conv}/$(basename "${f%.*}.${video_ext}")"
- if [ -e "$f" ] && [ ! -e "$out" ]; then
+ if [ ! -f "$out" ]; then
+ if ! regeximatch "$(file -ib "$f")" "^image\/"; then
+ die "input image $f is invalid ($(file -b "$f"))"
+ fi
printf 'in: %s, out: %s\n' "$f" "$out"
fit_img_16_9 "$f" "${out%.*}.jpg"
video_from_img "${out%.${video_ext}}.jpg" "${out}"
t@@ -96,18 +112,17 @@ if [ ! -f "bitreich-tv.${video_ext}" ]; then
title_slide bitreich-tv bitreich-tv.${video_ext}
fi
-
-# make title slides for video and converted images and encode to common codec
+# make title slides for video and converted images and encode all video clips …
for f in "$memecache"/*.mkv \
"$memecache"/*.mp4 \
"$memecache"/*.webm \
"$memecache_conv"/*."${video_ext}"; do
- title_path="${title}/$(basename "${f%.*}.webm")"
- [ ! -e "$title_path" ] && title_slide "$f" "$title_path"
+ title_path="${title}/$(basename "${f%.*}.${video_ext}")"
+ [ ! -f "$title_path" ] && title_slide "$f" "$title_path"
- out="${memecache_conv}/$(basename "${f%.*}.webm")"
- [ ! -e "$out" ] && video_conv "$f" "$out"
+ out="${memecache_conv}/$(basename "${f%.*}.${video_ext}")"
+ [ ! -f "$out" ] && video_conv "$f" "$out"
done
# generate random playlist from converted memes and add title slides
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.