threshold¶
Watch on youtube.comIgnore the keyword `min values’ and `max values’ in the official document, otherwise you will be confused. The usage and the meaning of this filter should be understood immediately if you just read the following sentence:
For example if first stream pixel’s component value is less than threshold value of pixel component from 2nd threshold stream, third stream value will picked, otherwise fourth stream pixel component value will be picked.
Example 1
00:00:00#! /bin/sh
ifn="Pexels_852411.mp4"
#
ffmpeg -y \
-i "${ifn}" \
-filter_complex "
color=gray:s=1280x720:d=30[th];
color=black:s=1280x720:d=30[ifle];
color=white:s=1280x720:d=30[ifot];
[0:v][th][ifle][ifot]threshold" result.mp4
Example 2
00:00:30#! /bin/sh
ifn="Pexels_852411.mp4"
#
ffmpeg -y \
-i "${ifn}" \
-filter_complex "
color=gray:s=1280x720:d=30[th];
color=white:s=1280x720:d=30[ifle];
color=black:s=1280x720:d=30[ifot];
[0:v][th][ifle][ifot]threshold" result.mp4
Example 3
00:01:00#! /bin/sh
ifn="Pexels_852411.mp4"
#
ffmpeg -y \
-i "${ifn}" \
-filter_complex "
color=gray:s=1280x720:d=30[th];
color=blue:s=1280x720:d=30[ifle];
[0:v]trim=0:30,setpts=PTS-STARTPTS[ifot];
[0:v][th][ifle][ifot]threshold" result.mp4
Example 4
00:01:30#! /bin/sh
ifn="Pexels_852411.mp4"
#
ffmpeg -y \
-i "${ifn}" \
-i "Pexels Videos 1051550.mp4" \
-filter_complex "
[1:v]trim=0:30,setpts=PTS-STARTPTS,fps=25,split[th][ifle];
[0:v]trim=0:30,setpts=PTS-STARTPTS[ifot];
[0:v][th][ifle][ifot]threshold" result.mp4