When encoding to webm (specifically VP8, i.e. libvpx), the color range gets reduced from 0-255 to 15-235. This causes a washed-out look; blacks become faded and not as sharp.
I have found solutions to this problem for mp4, but can't find one for webm. (With an mp4, you can add -pix_fmt yuvj420p
. I have tested that and it works for mp4. However, libvpx does not recognize this option.)
The command I'm using is ffmpeg -i in.avi -c:v libvpx -crf 8 -b:v 5M -an out.webm
Update: while the below comment fixed the problem for me, I've noticed that browsers seem to do some of their own color conversion when displaying video. It looks like they do a TV->PC conversion, eliminating a lot of the washed-out look of video. Possibly they do this to account for the fact that most video is in the clipped range. When playing my improved version, the blacks look overly dark, and I prefer the original version.
But when played in VLC, the improved version shows the full color range I wanted. So I think whether you use this technique depends on where the intend the video to be played. In VLC I would; in a browser, I wouldn't.
ffmpeg -i in.avi -c:v libvpx -crf 8 -b:v 5M -an out.webm
. Although from searching it seems that either most codecs do that by default, or ffmpeg does (I'm a new to manipulating color spaces, although I understand what they are).ffmpeg -i in.avi -vf "scale=in_range=pc:out_range=tv" -c:v libvpx -crf 8 -b:v 5M -an out.webm
out_range=pc
did! (I figure that was a typo, since output range=tv is what we were trying to avoid). Thank you! I had read about another hack using the scale filter, and tried it, but the command didn't work. If you'll make that an answer I'll accept it.