Skip to content

Instantly share code, notes, and snippets.

@luxigo
Created June 21, 2020 23:01
Show Gist options
  • Save luxigo/a49a9c12b87f7ac20676e35a7129e000 to your computer and use it in GitHub Desktop.
Save luxigo/a49a9c12b87f7ac20676e35a7129e000 to your computer and use it in GitHub Desktop.
Blend original video with edge detection filter output using multiply operator with ffmpeg
#!/bin/bash
INPUT=$1
OUTPUT=$2
if [ -z "$OUTPUT" ] ; then
EXT=${INPUT##*.}
BASENAME=$(basename -- $INPUT .$EXT)
OUTPUT=$(dirname $INPUT)/$BASENAME-composite.$EXT
fi
# to add some processing steps using filter_complex below (eg color correction)
# check https://ffmpeg.org/ffmpeg-filters.html
ffmpeg \
-i "$INPUT" \
-filter_complex " \
[0:v]sobel=planes=0xf:scale=1,negate [sob]; \
[0:v][sob]blend=all_mode=multiply \
" \
-preset veryslow \
-tune film \
-crf 15 \
-c:a copy \
-pix_fmt yuv420p \
-movflags \
+faststart \
"$OUTPUT"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment