bitreich-tv

meme tv encoding and streaming
git clone git://src.adamsgaard.dk/bitreich-tv
Log | Files | Refs Back to index

brtv-generate-title-slides.sh (1186B)


      1 #!/bin/sh
      2 # generate title slide animation for each hashtag in file specified by stdin.
      3 # stdin would typically be annna's module/hashtags/hashtags.txt
      4 # requirements: ffmpeg(1), convert(1)
      5 
      6 
      7 ### CONFIGURATION START
      8 
      9 # output title animations dir
     10 title="title"
     11 
     12 # ffmpeg flags for generated videos
     13 video_ext="webm"
     14 ffmpeg_codec="-loglevel error -acodec libopus -b:a 96K -vcodec libvpx -b:v 64k -f webm -vf scale=1280:-1 -r 30 -ac 2"
     15 
     16 # target video resolution
     17 video_resolution=1280x720
     18 
     19 # slide style
     20 bgcolor=magenta
     21 fgcolor=white
     22 
     23 # show title slides for this duration [s]
     24 title_display_time=5
     25 
     26 ### CONFIGURATION END
     27 
     28 
     29 temp="$(mktemp).png"
     30 
     31 title_slide() {
     32 	convert -size "$video_resolution" "xc:${bgcolor}" \
     33 		-pointsize 48 -fill "$fgcolor" \
     34 		-gravity center -draw "text 0,0 '${1}'" "$temp"
     35 	ffmpeg -y \
     36 		-f lavfi \
     37 		-i anullsrc=r=48000 \
     38 		-i "$temp" \
     39 		-t "${title_display_time}" \
     40 		$ffmpeg_codec \
     41 		"$2" < /dev/null
     42 	printf '%s\n' "$2"
     43 }
     44 
     45 mkdir -p "$title"
     46 
     47 # make title slide for every tag in first column of stdin
     48 # (if title slide doesn't already exist)
     49 while read -r tag url; do
     50 	out="${title}/${tag#\#}.${video_ext}"
     51 	[ ! -f "$out" ] && title_slide "$tag" "$out"
     52 done