Skip to content

Instantly share code, notes, and snippets.

@Wikinaut
Created February 1, 2021 19:51
Show Gist options
  • Save Wikinaut/5a74647719982be558120194eb5ca2c6 to your computer and use it in GitHub Desktop.
Save Wikinaut/5a74647719982be558120194eb5ca2c6 to your computer and use it in GitHub Desktop.
Breaking-News-Generator
#!/bin/bash
# Imagegenerator for "Breaking News"
# Init 20210112
if [[ $# -ne 3 ]] ; then
echo "Usage:"
echo "breaking-news imagefile \"headline-text\" \"yellow-ribbon-text\""
exit
fi
nowhour=$(date +"%H:%M")
now=$(date +"%Y%m%d-%H%M%S")
font="Dosis-Bold"
text="$(echo $2 | sed -e "s/ /_/g" -)"
outfile="${now}-breakingnews_${text}-${1%.*}.png"
ffmpeg -i "$1" -filter_complex '[0:v]scale=ih*16/9:-1,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[bg];[bg][0:v]overlay=(W-w)/2:(H-h)/2,crop=h=iw*9/16' -f image2pipe - | \
convert - -resize 1280x720 -background black -gravity center -extent 1280x720 \
-gravity center -font $font \
-fill "#d72c23" -draw "rectangle 14,430 450,470" \
-fill "#821a18" -draw "rectangle 14,470 450,510" \
-fill white -background "#00000000" -size 450x80 caption:"BREAKING NEWS" -geometry -410+110 \
-composite \
-fill black -background "#dedede80" -size 1266x110 caption:"$2" -geometry +7+206 \
-composite \
-fill black -background "#feeb1a80" -pointsize 36 -size 1165x60 caption:"$3" -geometry +57+291 \
-composite \
-fill white -background black -size 101x60 -pointsize 28 caption:"$nowhour" -geometry -575+291 \
-composite \
-fill white -background "#c2150f" -size 105x60 -pointsize 50 caption:"LIVE" -geometry -574-290 \
-composite \
"${outfile}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment