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.
For H.264 video using the encoder libx264 use:
- 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.