Skip to content

Instantly share code, notes, and snippets.

@apcro
Forked from cfr/devert
Last active November 9, 2019 07:10
Show Gist options
  • Save apcro/51de6f26fef88ba4f1ecde712b913dfa to your computer and use it in GitHub Desktop.
Save apcro/51de6f26fef88ba4f1ecde712b913dfa to your computer and use it in GitHub Desktop.
Fix vertical video by placing a blurred image in the background. This script accepts a width/height for resizing.
#!/usr/bin/env sh
# original from http://stackoverflow.com/a/30819570/187663
if [ $# -lt 2 ]
then
echo "Usage: devert {input video filename} {input image filename}"
echo "Usage: devert {input video filename} {input image filename} {width} {height}"
echo ""
echo "Excluding the width and height will generate a video at 1280x720"
exit;
fi
inputvideo=$1
inputimage=$2
width=${3:=1280}
height=${4:=720}
ffmpeg -i $inputvideo -i $inputimage -filter_complex "[0:v]scale=-1:$height[scaled_video];[1:v]scale=$width:$height,boxblur=16[blur_image];[blur_image][scaled_video]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[outv]" -c:v libx264 -aspect $width/$height -map [outv] -map 0:a -c:a copy $inputvideo.landscape.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment