3

I need to reduce the file size of an mp4 video. I don't need color information at all but pixel brightness resolution must be preserved. Videos consist of white background with a few (important) black dots of about 5px diameter. I am confused about what the best method/output would be.

2 Answers 2

3

Without knowing the video properties, my generic answer is

ffmpeg -i in.mp4 -vf geq=lum='p(X,Y)':cb=128:cr=128 out.mp4

This will reset the color information, but pass the luma plane intact. Add -crf 0 for truly lossless re-encoding.


This is the faster way,

ffmpeg -i in.mp4 -vf extractplanes=y,format=yuv420p out.mp4

The luma plane is extracted, and then neutral chroma planes are added in the pixel format conversion. This 2nd step is added because otherwise ffmpeg will auto-convert pixel format to yuv444 which isn't widely compatible.

2
  • Awesome, that works. Is this the quickest way? If not, what information would need to know for a faster/better solution? Commented Mar 18, 2018 at 0:37
  • There's one potentially quicker way but I have to check whether it alters the luma.
    – Gyan
    Commented Mar 18, 2018 at 8:18
2

Much faster solution: ffmpeg -i in.mp4 -vf extractplanes=y out.mp4

2
  • What makes that faster? Can you explain the -vf option so that others can solve their own problems in the future? Commented Mar 18, 2018 at 22:38
  • User wants luma plane only, so this command do that efficiently. Also geq filter is GPL and slow in almost any scenario.
    – user12174
    Commented Mar 19, 2018 at 8:18

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.