Skip to content

Instantly share code, notes, and snippets.

@coderofsalvation
Created November 9, 2020 08:50
Show Gist options
  • Save coderofsalvation/bb922e8e9cfed101ad4e9e1700d9ef25 to your computer and use it in GitHub Desktop.
Save coderofsalvation/bb922e8e9cfed101ad4e9e1700d9ef25 to your computer and use it in GitHub Desktop.
add gradient with angle on top of video or image using ffmpeg
#!/bin/bash
[[ ! -n $5 ]] && echo "Usage: [ROTATE=90] gradientvideo <input.mp4> <r> <g> <b> <output.mp4>" && exit
set -x
[[ -n $ROTATE ]] && ROTATE=",scale=w=1.5*iw:h=1.5*ih,rotate=angle=$ROTATE"
ffmpeg -i "$1" -filter_complex "[0]split[v0][v1];[v0]format=rgba,geq=r=$2:g=$3:b=$4:a=255*(Y/H)$ROTATE[fg];[v1][fg]overlay=(W-w)/2:(H-h)/2:shortest=1" -q:v 2 "$5"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment