Generate title slides in separate script - bitreich-tv - Meme TV encoding and s… | |
git clone git://bitreich.org/bitreich-tv git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfr… | |
Log | |
Files | |
Refs | |
Tags | |
LICENSE | |
--- | |
commit 514e6788b34aa2fea81e685a03b0f0bc9e449157 | |
parent 9e67470e2373361dea9c5707f30323bff524023d | |
Author: Anders Damsgaard <[email protected]> | |
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(-) | |
--- | |
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… | |
+ | |
+# 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 |