I have a few digital camera movies recorded in MJPEG that are taking a few GB of storage space. I would like to better compress them, but losing as little detail as possible, or none.

Since MJPEG doesn't compress across frames, I think that any modern movie codec would do a better job, wouldn't it?

Would the following ffmpeg command do what I expect?

ffmpeg -i input -c:v libx264 -preset veryslow -qp 0 output.mp4
  • "Since MJPEG doesn't compress across frames" — Do you mean compensate motion in frames? – tripulse Nov 10 '19 at 2:51

Your command will do it but the chief draw of x264 is the ability to provide high compression while maintaining subjective visual transparency. x264 will be of modest use if you keep to strict lossless mode. I suggest trying the following command:

ffmpeg -i input -c:v libx264 -preset veryslow -crf 18 output.mp4

If you don't like the quality, lower the CRF value.

| improve this answer | |

To store video data in H.264 without losing quality, you'd do:

ffmpeg -i input -c:v libx264 -crf 0 output.mp4

This not only retains the perceptual quality but also doesn't let the video to loose any bit.

| improve this answer | |

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.