Convert Video to Grayscale
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!
![Convert XML to JSON with JavaScript]()
If you follow me on Twitter, you know that I've been working on a super top secret mobile application using Appcelerator Titanium. The experience has been great: using JavaScript to create easy to write, easy to test, native mobile apps has been fun. My...
![Chris Coyier’s Favorite CodePen Demos]()
David asked me if I'd be up for a guest post picking out some of my favorite Pens from CodePen. A daunting task! There are so many! I managed to pick a few though that have blown me away over the past few months. If you...
![Create Custom Events in MooTools 1.2]()
Javascript has a number of native events like "mouseover," "mouseout", "click", and so on. What if you want to create your own events though? Creating events using MooTools is as easy as it gets.
The MooTools JavaScript
What's great about creating custom events in MooTools is...
![JavaScript Speech Recognition]()
Speech recognition software is becoming more and more important; it started (for me) with Siri on iOS, then Amazon's Echo, then my new Apple TV, and so on. Speech recognition is so useful for not just us tech superstars but for people who either want to work "hands...
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.
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
In my case, the file size dropped to 1/3 of original file.
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?