I created a small video with threshold filter to get black and white pixels (no greyscale):

ffmpeg -y -i /dev/video0
          -f lavfi -i color=0x606060:s=640x480
          -f lavfi -i color=black:s=640x480 -f lavfi
          -i color=white:s=640x480 -filter_complex threshold
          -c:v libx264 -c:a copy  test.mp4

Then I tried to convert it as a APNG file with white pixels as transparent (chromakey filter).

ffmpeg -y -i  test.mp4 -f apng -vf chromakey=white test.apng

This command converts all the pixels into transparent (checked with Gimp, it sets alpha of all pixels to 0).

Why? Also, how can I fix the command to make it work?

1 Answer 1


I finally found how to do that in one ffmpeg command, using colorkey:

ffmpeg  -y -i /dev/video0
           -f lavfi -i color=0x6a6a6a:s=640x480
           -f lavfi -i color=black:s=640x480
           -f lavfi -i color=white:s=640x480
           -filter_complex 'threshold,colorkey=white'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.