Generate title slides in separate script - bitreich-tv - Meme TV encoding and streaming
 (HTM) git clone git://bitreich.org/bitreich-tv git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/bitreich-tv
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) LICENSE
       ---
 (DIR) commit 514e6788b34aa2fea81e685a03b0f0bc9e449157
 (DIR) parent 9e67470e2373361dea9c5707f30323bff524023d
 (HTM) Author: Anders Damsgaard <anders@adamsgaard.dk>
       Date:   Sun, 16 Aug 2020 20:09:05 +0200
       
       Generate title slides in separate script
       
       Diffstat:
         A brtv-generate-title-slides.sh       |      64 +++++++++++++++++++++++++++++++
       
       1 file changed, 64 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/brtv-generate-title-slides.sh b/brtv-generate-title-slides.sh
       @@ -0,0 +1,64 @@
       +#!/bin/sh
       +# generate title slide animation for each hashtag in file specified by stdin.
       +# stdin would typically be annna's module/hashtags/hashtags.txt
       +# requirements: ffmpeg(1), convert(1)
       +
       +
       +### CONFIGURATION START
       +
       +# output 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"
       +
       +# target video resolution
       +video_resolution=1280x720
       +
       +# slide style
       +bgcolor=magenta
       +fcolor=white
       +
       +# show title slides for this duration [s]
       +title_display_time=5
       +
       +### CONFIGURATION END
       +
       +
       +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##*/} <hashtags-file>"
       +fi
       +
       +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"
       +}
       +
       +mkdir -p "$title"
       +
       +# make title slide for every file in $1/ if they do not already exist
       +while IFS='
       +' read -r line; do
       +        out_path="${title}/$(basename "${f%.*}.${video_ext}")"
       +        [ ! -f "$out_path" ] && title_slide "$f" "$out_path"
       +done