Convert a video file with ffmpeg

Transcode any input video to MP4 (H.264 + AAC) with sensible quality settings for sharing and playback everywhere.

LinuxTerminalmediaLow risk
Run ffmpeg -i input.mov -c:v libx264 -crf 20 -c:a aac output.mp4 to convert a video to broadly compatible MP4.

01Command

Command
$ ffmpeg -i input.mov -c:v libx264 -crf 20 -c:a aac output.mp4

02What it does

ffmpeg infers formats from file extensions; the example re-encodes video to H.264 and audio to AAC, which every browser and phone plays. -crf sets constant quality: lower is better and larger (18 near-lossless, 23 default, 28 much smaller). To copy without re-encoding (fast, no quality loss, only works if codecs already fit the container) use ffmpeg -i input.mov -c copy output.mp4. Check what a file actually contains first with ffprobe input.mov, and scale with -vf scale=1280:-2. Use -y to overwrite an existing output without prompting.

03Risk

RiskLow risk
Requirementsffmpeg installed (sudo apt install ffmpeg / sudo dnf install ffmpeg); the output file must not exist unless you pass -y
!Warning: Re-encoding is lossy and slow for long videos — if the source is already H.264/AAC in a wrong container, -c copy converts in seconds with no quality loss.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • FFmpeg Documentation
    FFmpeg · vendor-doc · 2026-09-17
    Evidence: The FFmpeg documentation describes -i for the input file, -c:v / -c:a codec selection, and CRF-based quality for x264 encoding.

Last verified: 2026-09-17 · Category: Media

06Related solutions