3

I am currently using an FFMPEG command like:

ffmpeg -i input.mov -vf scale=1920:1080 output.mp4

to convert varying input format file to a fixed resolution MP4 output file. One final step I need is to make the output Black and White (the input files will be full color).

I have tried both -pix_fmt gray and -vf format=gray,format=yuv422p

but both just result in a black output video.

After much trawling of google, it looks like the FFMPEG exe I downloaded (for windows) wasn't compiled with the "-enable-gray" option, but I don't know if this makes any difference and don't know how to obtain a windows FFMPEG with this option enabled (building FFMPEG myself looks like a lot of hard work). Any advice welcome! Thanks.

PS I should add that the conversion I'm currently doing and any grayscale conversion could be separate steps if required.

6

Yes, you do need a ffmpeg build with gray pixel format enabled. You should get your binary from the Windows link at ffmpeg. Download the latest 32-bit static build.

You can check if your build has gray enabled by running

ffmpeg -pix_fmts | findstr /r gray

It should list an entry for gray.

And use format=gray in your vf chain and -pix_fmt yuv420p together for broad compatibility.

The command below is for linux. grep will work as findstr!

ffmpeg -pix_fmts | grep -i gray
  • Running your command on my current FFMPEG results in IO... gray 1 8 IO... gray16be 1 16 IO... gray16le 1 16 Does this mean it has gray enabled? – WoogieBoogie Mar 31 '16 at 10:55
  • Ok, just follow the last line of my answer. Should work with your current build. – Gyan Mar 31 '16 at 11:16
  • Running the command ffmpeg -i input.mov -vf format=gray -pix_fmt yuv420p output.mp4 results in a black screen. I wonder if trying to do the conversion from .mov to mp4 at the same time is the problem? Now I think of it I'll try separate commands – WoogieBoogie Mar 31 '16 at 12:43
  • Separating out the conversion from .mov -> .mp4 and the conversion to grayscale (using your commands) worked. Thanks :) – WoogieBoogie Mar 31 '16 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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