FFMPEG - convert video to Black & White with threshold? I'd like to convert videos to black and white but also specify the threshold of what to convert to black/white.

I'm currently using cv2 to do this successfully using the 2 lines below (first converts to grayscale then B&amp;W). But it would help my workflow to do everything with FFMPEG if possible.

    grayFrame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
    (thresh, BW) = cv2.threshold(grayFrame, 10, 255, cv2.THRESH_BINARY)
Use the threshold filter:



ffmpeg -i main_1280x720.mp4 -f lavfi -i color=gray:s=1280x720 -f lavfi -i color=black:s=1280x720 -f lavfi -i color=white:s=1280x720 -filter_complex threshold output.mkv


This filter requires four video streams to perform thresholding:


main input
threshold
min
max


You can optionally add the format filter for a grayscale pixel format: threshold,format=gray (assuming your output format supports that otherwise additional pixel format conversion will automatically take place).