URI: 
       Remove old wip script - bitreich-tv - Meme TV encoding and streaming
  HTML git clone git://bitreich.org/bitreich-tv git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-tv
   DIR Log
   DIR Files
   DIR Refs
   DIR Tags
   DIR LICENSE
       ---
   DIR commit 02c0fc491be147c4438d80ca59557b02fdffce21
   DIR parent ac639f0d7f8feadca0ef246d65bcc039fd73e90a
  HTML Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Sun, 16 Aug 2020 22:20:50 +0200
       
       Remove old wip script
       
       Diffstat:
         D brtv-start.sh                       |     166 -------------------------------
       
       1 file changed, 0 insertions(+), 166 deletions(-)
       ---
   DIR diff --git a/brtv-start.sh b/brtv-start.sh
       @@ -1,166 +0,0 @@
       -#!/bin/sh
       -# generate title animations and start streaming to server
       -# requirements: ffmpeg(1), convert(1)
       -
       -### CONFIGURATION START
       -
       -# intermediate playlist file
       -playlist="playlist_$(date +%Y-%m-%d)"
       -
       -# memecache source dir
       -memecache="$1"
       -
       -# converted memecache dir
       -memecache_conv="memecache_conv"
       -
       -# title animations dir
       -title="title"
       -
       -# ffmpeg flags for generated videos
       -video_ext="webm"
       -ffmpeg_codec="-loglevel error -acodec libopus -b:a 96K -vcodec libvpx -b:v 64k -f webm -vf scale=1280:-1 -r 30 -ac 2"
       -out_video="brtv_$(date +%Y-%m-%d).${video_ext}"
       -#out_video_duration="24:00:00"
       -out_video_duration="00:05:00"
       -
       -# target video resolution
       -video_resolution=1280x720
       -
       -# slide style
       -bgcolor=magenta
       -fcolor=white
       -
       -# show image memes for this duration [s]
       -image_display_time=10
       -
       -# show title slides for this duration [s]
       -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" \
       -                xc:"$bgcolor" +swap -gravity center -composite "$2"
       -}
       -
       -video_from_img() {
       -        printf 'image to video %s -> %s\n' "$1" "$2"
       -        ffmpeg -y \
       -                -f lavfi \
       -                -i anullsrc=r=48000 \
       -                -i "$1" \
       -                -t "${image_display_time}" \
       -                $ffmpeg_codec \
       -                "$2";
       -}
       -
       -title_slide() {
       -        img="$(basename "${1%.*}".png)"
       -        printf 'title_slide %s -> %s\n' "$1" "$img"
       -        convert -size "$video_resolution" "xc:${bgcolor}" \
       -                -pointsize 48 -fill "$fgcolor" \
       -                -gravity center -draw "text 0,0 '#${img%.*}'" "$img"
       -        ffmpeg -y \
       -                -f lavfi \
       -                -i anullsrc=r=48000 \
       -                -i "$img" \
       -                -t "${title_display_time}" \
       -                $ffmpeg_codec \
       -                "$2" && rm "$img"
       -}
       -
       -video_conv() {
       -        printf 'encode %s -> %s\n' "$1" "$2"
       -        if ! regeximatch "$(file -ib "$f")" "^video\/"; then
       -                die "input video $1 is invalid ($(file -b "$1"))"
       -        fi
       -        ffmpeg -y -i "$1" $ffmpeg_codec "$2"
       -}
       -
       -mkdir -p "$title"
       -mkdir -p "$memecache_conv"
       -
       -# generate video from each image
       -for f in "$memecache"/*.jpg \
       -        "$memecache"/*.jpeg \
       -        "$memecache"/*.JPG \
       -        "$memecache"/*.png \
       -        "$memecache"/*.PNG; do
       -        out="${memecache_conv}/$(basename "${f%.*}.${video_ext}")"
       -        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}"
       -        fi
       -done
       -
       -# make animation for fallback stream
       -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 all video clips to common codec
       -for f in "$memecache"/*.mkv \
       -         "$memecache"/*.mp4 \
       -                 "$memecache"/*.webm \
       -                 "$memecache_conv"/*."${video_ext}"; do
       -
       -        title_path="${title}/$(basename "${f%.*}.${video_ext}")"
       -        [ ! -f "$title_path" ] && title_slide "$f" "$title_path"
       -
       -        out="${memecache_conv}/$(basename "${f%.*}.${video_ext}")"
       -        [ ! -f "$out" ] && video_conv "$f" "$out"
       -done
       -
       -# generate random playlist from converted memes and add title slides
       -find "$memecache_conv" -maxdepth 1 -name "*.webm" -type f | \
       -        sort -R | \
       -        awk -v memecachedir="$memecache" -v titledir="$title" '
       -        function add_title(s) {
       -                sub(/memecache/, "title", s);
       -                return s
       -        }
       -        {line=$0;
       -        print "file \""add_title($line)"\"";
       -        print "file \""$0"\""}' | sed "s/\"/'/g" > "$playlist"
       -
       -#printf '\nstarting fallback stream\n'
       -#ffmpeg -loglevel quiet \
       -#        -stream_loop -1 -i bitreich-tv.webm
       -#        -f webm -codec copy
       -#        icecast://source:${pass}@localhost:8000/brtvfallback
       -
       -
       -# encode daily video file
       -ffmpeg -n -f concat -safe 0 -i "$playlist" \
       -        -f "${video_ext}" -cluster_size_limit 2M -cluster_time_limit 5100 -content_type video/webm \
       -        -codec copy \
       -        -to "$out_video_duration" 
       -        "$video_out"
       -
       -printf '\nstarting stream\n'
       -
       -ffmpeg -f concat -safe 0 -stream_loop -1 -i "$video_out" \
       -        -f webm -cluster_size_limit 2M -cluster_time_limit 5100 -content_type video/webm \
       -        -analyzeduration 2M -probesize 2M \
       -        -codec copy \
       -        -deadline realtime -threads 4 \
       -        icecast://source:${pass}@adamsgaard.dk:3232/brtv