Convert Video to Grayscale

By  on  

I'm a JavaScript fanatic but I've always been fascinated with media manipulation. Maybe it's because I've secretly always wanted to be a designer, but I'm fine with being able to manipulate art with software instead of create the art myself. One type of art I've always enjoyed was black and white (/grayscale) video.

To convert a video to black and white, you can utilize ffmpeg with a few simple arguments:

ffmpeg -i input.mp4 -vf hue=s=0 output.mp4

The preceding command turns this color video:

... to the following grayscale video:

If you were to search ffmpeg on this blog, you'd find dozens of tutorials about how amazing the tool is. Play around with ffmpeg and let me know what awesomeness you come up with!

Recent Features

  • By
    LightFace:  Facebook Lightbox for MooTools

    One of the web components I've always loved has been Facebook's modal dialog.  This "lightbox" isn't like others:  no dark overlay, no obnoxious animating to size, and it doesn't try to do "too much."  With Facebook's dialog in mind, I've created LightFace:  a Facebook lightbox...

  • By
    Creating Scrolling Parallax Effects with CSS

    Introduction For quite a long time now websites with the so called "parallax" effect have been really popular. In case you have not heard of this effect, it basically includes different layers of images that are moving in different directions or with different speed. This leads to a...

Incredible Demos

  • By
    Hot Effect: MooTools Drag Opacity

    As you should already know, the best visual features of a website are usually held within the most subtle of details. One simple trick that usually makes a big different is the use of opacity and fading. Another awesome MooTools functionality is...

  • By
    Modal-Style Text Selection with Fokus

    Every once in a while I find a tiny JavaScript library that does something very specific, very well.  My latest find, Fokus, is a utility that listens for text selection within the page, and when such an event occurs, shows a beautiful modal dialog in...

Discussion

  1. Nice, ffmpeg seems to be quite handy!

    Btw the same effect may be achieved on the client using CSS grayscale-filter, which is nowadays supported by any major browser (but IE). E.g. https://codepen.io/MattDiMu/pen/pBqQqR

    Doing this on the client-side, however, will probably result in much larger file sizes than necessary, as grayscale videos offer much better compression. In your example the difference is 399kB vs 270kB.

  2. Tom Gallagher

    I noticed the file size difference as well.

    David, could you confirm that just adding -vf hue=s=0 reduced the file size by 129KB, there were no other transformations?

    Thanks

    • Denis

      In my case, the file size dropped to 1/3 of original file.

  3. Hey David! Since there is difference between BLACK AND WHITE filter and GRAYSCALE filter.

    A truly black and white image would simply consist of two colors—black and white. Grayscale images are created from black, white, and the entire scale of shades of gray.

    Is method you mentioned rather grayscale? Or rather black and white filter?

Wrap your code in <pre class="{language}"></pre> tags, link to a GitHub gist, JSFiddle fiddle, or CodePen pen to embed!