DEV Community

Cover image for 🎬 How to Convert and Compress MOV to MP4 Using FFmpeg on macOS (Without Losing Quality)
Rafa Rafael
Rafa Rafael

Posted on

🎬 How to Convert and Compress MOV to MP4 Using FFmpeg on macOS (Without Losing Quality)

As developers, we often deal with images, scripts, and occasionally... Videos. While images are usually optimized, videos can quickly become a storage and bandwidth nightmare if not properly compressed.

🧩 A Real-World Developer Scenario

Imagine you're building a portfolio site for a client who owns a video production company. They’ve handed you several .mov files. Crisp, high-definition showcase reels of their work to embed on their homepage and project pages.

You upload the first video to your server and immediately hit a roadblock: the file size is over 1GB for a 2-minute clip. Not only does this eat up server storage, but loading that video on the front page seriously slows down performance. Especially on mobile devices. And you haven’t even started on the other videos.

That’s where video compression comes in.


πŸš€ Why Compress Videos?

Here are some compelling reasons to compress .mov videos into smaller .mp4 files:

βœ… 1. Faster Load Times

Smaller videos load faster and reduce page weight, improving the user experience.

βœ… 2. Lower Hosting Costs

Fewer megabytes mean less disk space and bandwidth usage on your hosting plan.

βœ… 3. Improved SEO

Page speed is a ranking factor for Google. Lightweight videos help you climb search results.

βœ… 4. Better Compatibility

modern browsers and devices universally support .mp4 files using H.264, .mov is not.

βœ… 5. Retain Quality

With the right tools, you can compress videos without noticeable loss of quality.


πŸ› οΈ Enter ffmpeg: Your Compression Power Tool

ffmpeg is a free and powerful command-line tool for video/audio conversion and compression. On macOS, it works perfectly with Homebrew.


πŸ§‘β€πŸ’» Step-by-Step: Convert and Compress .mov to .mp4

1. Install ffmpeg on macOS

brew install ffmpeg
Enter fullscreen mode Exit fullscreen mode

2. Basic Conversion & Compression Command

ffmpeg -i input.mov -vcodec libx264 -crf 28 -preset medium -acodec aac -b:a 128k output.mp4
Enter fullscreen mode Exit fullscreen mode

What This Does:

  • input.mov: Your original video
  • -vcodec libx264: Converts video to H.264 codec
  • -crf 28: Controls quality (lower = better, 23 is default, 28 is a good balance)
  • -preset medium: Speed vs file size (use slow for smaller output)
  • -acodec aac -b:a 128k: Compresses audio while keeping it clear
  • output.mp4: Your new, smaller video

πŸͺ„ Want to Shrink Resolution Too?

If your video is 4K but you only need 720p, add this:

-vf "scale=1280:-2"
Enter fullscreen mode Exit fullscreen mode

Example:

ffmpeg -i input.mov -vf "scale=1280:-2" -vcodec libx264 -crf 28 -preset medium -acodec aac -b:a 128k output.mp4
Enter fullscreen mode Exit fullscreen mode

This scales the width to 1280px and automatically adjusts the height to preserve the aspect ratio.


🧾 Bonus: Batch Convert All .mov Files in a Folder

If you have a lot of videos to convert, you can automate the process with a simple shell script:

πŸ“œ Shell Script: convert-all-mov.sh

#!/bin/bash

# Directory containing your .mov files
INPUT_DIR="./videos"
OUTPUT_DIR="./compressed"

# Create output directory if it doesn't exist
mkdir -p "$OUTPUT_DIR"

# Loop through all .mov files in the input directory
for file in "$INPUT_DIR"/*.mov; do
  # Get filename without extension
  filename=$(basename "$file" .mov)

  echo "Converting $filename.mov to $filename.mp4..."

  ffmpeg -i "$file" \\
    -vcodec libx264 -crf 28 -preset medium \\
    -acodec aac -b:a 128k \\
    "$OUTPUT_DIR/$filename.mp4"

  echo "βœ… Done: $filename.mp4"
done

echo "πŸŽ‰ All videos have been converted and saved to $OUTPUT_DIR"
Enter fullscreen mode Exit fullscreen mode

πŸ“¦ How to Use It

  1. Save the script as convert-all-mov.sh
  2. Create a folder named videos and put your .mov files inside
  3. Make the script executable:
chmod +x convert-all-mov.sh
Enter fullscreen mode Exit fullscreen mode
  1. Run it:
./convert-all-mov.sh
Enter fullscreen mode Exit fullscreen mode

πŸ“ Folder Structure Example

project/
β”œβ”€β”€ videos/          # contains your .mov files
β”œβ”€β”€ compressed/      # will contain the .mp4 output files
└── convert-all-mov.sh
Enter fullscreen mode Exit fullscreen mode

🧠 Final Thoughts

Compressing videos is not just about saving space. It’s about delivering a faster, smoother experience for your users. As developers, we should care about performance just as much as design and functionality.

With ffmpeg, you can quickly convert .mov files to .mp4, slash the file size, and still keep the quality sharp. Whether you're uploading to a blog, portfolio, SaaS app, or e-commerce store, this simple workflow is a game-changer.

Top comments (0)