FFmpeg is a powerful command-line tool for converting, recording, and processing audio and video files. On a Mac, you can use it to change formats, compress videos, extract audio, and more—all without installing a heavy GUI app. This guide walks you through installing FFmpeg and running the most common commands, with clear steps and troubleshooting for when things go wrong.
What You’ll Need
- A Mac running macOS (any recent version, from Catalina to Sonoma)
- Terminal access (found in /Applications/Utilities/Terminal.app)
- Homebrew installed (optional but recommended for easy installation)
- A video or audio file you want to process (e.g., MP4, MOV, MP3)
Step-by-Step
- Install Homebrew (if not already installed). Open Terminal and run:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)". Follow the prompts; this may take a few minutes. - Install FFmpeg via Homebrew. In Terminal, run:
brew install ffmpeg. Homebrew will download and install FFmpeg along with its dependencies. If you already have Homebrew, this is the quickest method. - Verify the installation. Run
ffmpeg -version. You should see version information and configuration details. If you see “command not found,” re-check the installation path. - Navigate to your file’s folder. Use
cdto change directories. For example, if your video is on the Desktop, run:cd ~/Desktop. You can also drag the folder into Terminal after typingcdto paste the path. - Check your input file. Run
ffmpeg -i input.mp4(replaceinput.mp4with your file’s name). This will show file info like codec, resolution, and bitrate. It will also print an error at the end (because no output is specified), but that’s normal. - Convert a video to another format. For example, to convert MP4 to MKV:
ffmpeg -i input.mp4 output.mkv. The output format is inferred from the file extension. For MP4 to AVI, useoutput.avi. - Compress a video (reduce file size). Use the H.264 codec and adjust the CRF (Constant Rate Factor) value. Lower CRF = higher quality, larger file. A common value is 28 for good compression:
ffmpeg -i input.mp4 -c:v libx264 -crf 28 -preset fast output.mp4. The-presetcontrols speed vs. compression efficiency. - Extract audio from a video. To save the audio as MP3:
ffmpeg -i input.mp4 -q:a 0 -map a output.mp3. The-map aselects only the audio stream. For lossless audio, use-c:a flacinstead. - Resize a video. To scale to 1280×720 (720p):
ffmpeg -i input.mp4 -vf scale=1280:720 output.mp4. You can also usescale=-2:720to keep the aspect ratio (the -2 ensures even dimensions). - Trim a video. To cut from 10 seconds to 30 seconds:
ffmpeg -i input.mp4 -ss 10 -t 20 -c copy output.mp4.-ssis the start time,-tis the duration. Using-c copycopies the streams without re-encoding, which is fast but less precise. - Combine audio and video. To replace the audio track in a video:
ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 output.mp4. The-mapoptions select which streams to use.
Common Mistakes
- Forgetting to specify the output format. FFmpeg infers the format from the file extension. If you type
outputwithout an extension, you’ll get an error. - Using the wrong file paths. If your file has spaces, you must quote the filename:
ffmpeg -i "my video.mp4". - Assuming the codec is supported. Some formats (like WMV) may require additional libraries. If you get “Unknown encoder,” you may need to install a build with more codecs, or convert to a more common format.
- Overwriting files without asking. FFmpeg will overwrite output files without warning. Use
-nto prevent overwriting, or-yto auto-confirm.
Tips
- Use the
-presetoption wisely. For H.264 encoding,ultrafastis quick but produces larger files;veryslowgives the best compression but takes longer. - Batch process multiple files. Use a loop in Terminal:
for i in *.mp4; do ffmpeg -i "$i" "${i%.mp4}.mkv"; done. This converts all MP4 files in the folder to MKV. - Check the FFmpeg documentation. The official docs at ffmpeg.org are thorough. Use
ffmpeg -h fullto see all options. - Use
-progressto monitor long encodes. Add-progress pipe:1to see progress in the terminal.
Troubleshooting
- “command not found” after installation. If Homebrew installed FFmpeg but Terminal can’t find it, your PATH may not include Homebrew’s bin directory. Run
export PATH="/opt/homebrew/bin:$PATH"(for Apple Silicon) orexport PATH="/usr/local/bin:$PATH"(for Intel) to fix it temporarily. To make it permanent, add that line to your~/.zshrcfile. - FFmpeg is slow or hangs. This is often due to a very high resolution or a slow preset. Try lowering the resolution or using a faster preset. Also, ensure your Mac has enough free disk space (FFmpeg needs space for temporary files).
- “Invalid data found when processing input.” This usually means the file is corrupted or not actually a video/audio file. Try opening the file in QuickTime to see if it plays.
- Audio is out of sync after conversion. This can happen when using
-c copywith trimming. Instead, re-encode the audio:ffmpeg -i input.mp4 -ss 10 -t 20 -c:v libx264 -c:a aac output.mp4.
Frequently Asked Questions
- Is FFmpeg free? Yes, FFmpeg is free and open-source software. It’s available under the LGPL/GPL license.
- How do I uninstall FFmpeg? If installed via Homebrew, run
brew uninstall ffmpeg. - Can I use FFmpeg to convert videos for iPhone? Yes, you can convert to H.264 with AAC audio, which is compatible with iPhone. For example:
ffmpeg -i input.mp4 -c:v libx264 -c:a aac -movflags +faststart output.mp4. - Does FFmpeg support hardware acceleration on Mac? Yes, you can use
-c:v h264_videotoolboxfor hardware encoding on Macs with Intel or Apple Silicon. This is faster but may produce slightly lower quality than software encoding. - How do I extract a frame from a video? Use
ffmpeg -i input.mp4 -ss 00:01:00 -vframes 1 frame.jpgto capture the frame at 1 minute. - Why is my output file larger than the input? This often happens when you use a high bitrate or a lossless codec. Use CRF compression (as in step 7) to reduce size, or check the bitrate with
-b:v 1000k.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.
More cards in this drawer
- Campus Tech Innovation Hubs: What They Are
- Poco C51 Airtel Prepaid Locked Variant India?
- Jenkins vs GitHub Actions: Which CI/CD Fits Your Team?
- Turn Off Backup Encryption in iTunes?
- Shared VPS Hosting: Is It Better?
- Disk Defrag Pro: What It Does and Whether You Need It