Last active
March 8, 2019 00:30
-
-
Save divisiondeariza/182629f32e3a3de9800c06fd6a4418e6 to your computer and use it in GitHub Desktop.
Well, a little script to make facebook friendly my videos. :)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: | |
# bash squarify.sh -i INPUTFILE -t "text" output.mp4 | |
# | |
# Options | |
# -i: input file | |
# -t text to overlay | |
while echo $1 | grep -q ^-; do | |
# Evaluating a user entered string! | |
# Red flags!!! Don't do this | |
eval $( echo $1 | sed 's/^-//' )="'$2'" | |
shift 2 | |
done | |
OUTPUT="$1" | |
WIDTH=`ffprobe -v error -select_streams v:0 -show_entries stream=width -of csv=s=x:p=0 $i` | |
HEIGHT=`ffprobe -v error -select_streams v:0 -show_entries stream=height -of csv=s=x:p=0 $i` | |
IMAGE=$(convert -fill dodgerblue -background black -font Roboto-Condensed-Bold -pointsize 72 \ | |
-size "$WIDTH"x -gravity Center \ | |
caption:"$t" -bordercolor black -border 40x40 \ | |
png:- | base64 ) | |
IMG_HEIGTH=`base64 --decode <<< $IMAGE | ffprobe -v error -select_streams v:0 -show_entries stream=height -of csv=s=x:p=0 pipe:0` | |
base64 --decode <<< $IMAGE | ffmpeg -i $i -i pipe:0 -filter_complex "[0:v]scale=-1:iw,boxblur=luma_radius=min(h\,w)/20:luma_power=1:chroma_radius=min(cw\,ch)/20:chroma_power=1[blurred];[blurred][0:v]overlay=(W-w)/2:(H-h + $IMG_HEIGTH)/2,crop=ih:ih[vid];[vid][1:v]overlay=(W-w)/2:(0)/4" $OUTPUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment