unix4artists/ffmpeg/filter/bipack_steps.sh

49 lines
884 B
Bash
Raw Normal View History

2021-05-08 16:53:26 +00:00
#!/bin/bash
set -e
W=1280
H=720
A=${1}
B=${2}
MATTE=${3}
OUTPUT=${4}
MATTE1=matte1.mov
MATTE2=matte2.mov
PASS1=pass1.mov
echo "Generating mattes from $MATTE..."
ffmpeg -y -i "$MATTE" -vf eq=saturation=0:contrast=100,smartblur=1 -c:v prores_ks -profile:v 4 "$MATTE1"
ffmpeg -y -i "$MATTE1" -vf negate -c:v prores_ks -profile:v 4 "$MATTE2"
echo "Applying matte to $A..."
ffmpeg -y -i "$A" -i "$MATTE1" \
-filter_complex 'color=0x000000:size=1280x720,format=rgb24[bla];[bla][0][1]maskedmerge' \
-c:v prores_ks \
-profile:v 4 \
-shortest \
"$PASS1"
echo "Cleaning up tmp matte files..."
rm "$MATTE1"
2021-05-09 20:10:35 +00:00
2021-05-08 16:53:26 +00:00
echo "Combining matted layers together into $OUTPUT_FILE..."
2021-05-09 20:10:35 +00:00
ffmpeg -y -i "$PASS1" -i "$B" -i "$MATTE2" \
-filter_complex '[0][1][2]maskedmerge' \
2021-05-08 16:53:26 +00:00
-c:v prores_ks \
2021-05-09 20:10:35 +00:00
-profile:v 4 \
2021-05-08 16:53:26 +00:00
-shortest \
2021-05-09 20:10:35 +00:00
"${OUTPUT}"
2021-05-08 16:53:26 +00:00
echo "Cleaning up temp files..."
2021-05-09 20:10:35 +00:00
rm "$MATTE2"
2021-05-08 16:53:26 +00:00
rm "$PASS1"