I'm dealing with some mp4 videos that were encoded on mobile phones and are pretty huge.

I think ffmpeg can do better. I'm trying to figure out what flags to use to preserve fps, resolution, and keep the appearance the same (lossless or near lossless).

What flags should I use?


Preserve settings

ffmpeg will automatically attempt to use many of the same parameters when encoding including: frame rate, width, height, pixel format, audio channel layout, audio sample rate, etc. So you usually don't have to do anything special.

Some settings may change if there are format or encoder restrictions.

Preserve quality

For H.264 video using the encoder libx264 use:

  • -crf 18
  • the slowest preset you have patience for

These options will output a lossy video, but it -crf 18 provides enough bits that it will likely be visually lossless or nearly so. If the output is still too big the general recommendation is to use the highest -crf value that still provides an acceptable quality.

You can change it to -crf 0 for true lossless, but the resulting output will be a huge file size–probably even bigger than the original.


ffmpeg -i input.mp4 -c:v libx264 -crf 18 -preset slow -c:a copy output.mp4

This example stream copies the audio instead of re-encoding it since the majority of the file size comes from video.

Development is very active, so make sure to use a recent build of ffmpeg. See the FFmpeg Download page for links to binaries.

Also see:


There is no such thing as 'lossless' if you want the size to be small. Lossless video means keeping the original bitstream, which does not reduce the size. Re-encoding is the only way to reduce the size of a video bitstream, which is a lossy process, and you're more likely to increase the size just to preserve the original quality and not add additional artifacts. True lossless (uncompressed) raw video is massive.

If your goal is a smaller file without compromising quality, simply re-encode the video with the lowest bit-rate that is visually acceptable. Try different codecs (x265 is more efficient than x264 etc, but less compatible). FFmpeg is a powerful tool for messing with encoder settings.

Another option is compressing the audio without touching the video, as some audio streams can be larger than needed (256kb/s AAC can go down to 128 or 96 depending on how important it is).

  • Just a note: you can totally have lossless compression. Just don't expect the file size reduction to be as small. – DaVince Nov 17 '20 at 15: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.