bitreich-tv

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

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


      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="/br/gopher/tv/title"
     11 
     12 # ffmpeg flags for generated videos
     13 video_ext="webm"
     14 ffmpeg_codec="-loglevel error -acodec libopus -b:a 96K -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 # logo to draw in background
     27 logo="bitreichtv.vtv"
     28 
     29 ### CONFIGURATION END
     30 
     31 
     32 temp="$(mktemp).png"
     33 
     34 title_slide() {
     35 	convert -font Courier -size "$video_resolution"  "xc:${bgcolor}" \
     36 		-gravity north -pointsize 22 \
     37 		-draw "text 0,80 '$(cat "$logo")'" \
     38 		-gravity south -pointsize 54 -fill "xc:${fgcolor}" \
     39 		-draw "text 0,100 '${1}'" "$temp"
     40 	ffmpeg -y \
     41 		-f lavfi \
     42 		-i anullsrc=r=48000 \
     43 		-i "$temp" \
     44 		-t "${title_display_time}" \
     45 		$ffmpeg_codec \
     46 		"$2" < /dev/null
     47 	printf '%s\n' "$2"
     48 }
     49 
     50 mkdir -p "$title"
     51 
     52 # make title slide for every tag in first column of stdin
     53 # (if title slide doesn't already exist)
     54 while read -r tag url; do
     55 	out="${title}/${tag#\#}.${video_ext}"
     56 	if [ ! -f "$out" ]; then
     57 		title_slide "$tag" "$out"
     58 	fi
     59 done