
This guide shows how to convert any video file to MP4 format using FFmpeg, while keeping the best possible quality and reducing file size. Each command includes a short explanation of what the parameters do.
🎥 FFmpeg — Convert to MP4 using H.264
Explanation: Converts video to MP4 using the H.264 codec with high quality settings.
-c:v libx264: Use H.264 video codec-crf 18: Constant Rate Factor (lower = better quality)-preset slow: Slower encoding = better compression-c:a aac: Use AAC audio codec-b:a 192k: Set audio bitrate to 192 kbps
FFmpeg
ffmpeg -i input.ext -c:v libx264 -crf 18 -preset slow -c:a aac -b:a 192k output.mp4
🎥 FFmpeg — Convert to MP4 using H.265
Explanation: Converts video to MP4 using the H.265 codec for smaller file size with similar quality.
-c:v libx265: Use H.265 video codec-crf 23: Balanced quality and size-preset medium: Medium encoding speed-c:a aac: Use AAC audio codec-b:a 192k: Set audio bitrate to 192 kbps
FFmpeg
ffmpeg -i input.ext -c:v libx265 -crf 23 -preset medium -c:a aac -b:a 192k output.mp4
🎥 FFmpeg — Copy Streams Without Re-encoding
Explanation: Copies video and audio streams directly into MP4 without changing codecs.
-c copy: Copy both video and audio as-is
FFmpeg
ffmpeg -i input.ext -c copy output.mp4
🎥 FFmpeg — Preserve Resolution and Frame Rate
Explanation: Keeps the original video size and frame rate during conversion.
-vf "scale=iw:ih": Keep input width and heightfps=fps: Keep original frame rate
FFmpeg
ffmpeg -i input.ext -c:v libx264 -crf 20 -preset slow -c:a aac -b:a 192k -vf “scale=iw:ih,fps=fps” output.mp4
🎥 FFmpeg — Preserve Metadata
Explanation: Keeps original file metadata like creation date and tags.
-map_metadata 0: Copy metadata from input
FFmpeg
ffmpeg -i input.ext -map_metadata 0 -c:v libx264 -crf 20 -preset slow -c:a aac -b:a 192k output.mp4