How to Merge MP4 Files Using macOS Automator - Simple DIY Solution
Ever needed to combine multiple MP4 videos into a single file? Whether you're working with clips from Instagram, combining scenes from a longer recording, or creating a compilation, merging video files is a common need. While there are plenty of third-party applications available, macOS users have a powerful built-in solution: Automator.
In this guide, we'll show you how to create a simple Automator script that lets you merge selected MP4 files with just a few clicks - no coding knowledge required!
What You'll Need
- A Mac running macOS (this works on all recent versions)
- ffmpeg installed (we'll cover this in the steps)
- Two or more MP4 files you want to merge
- A few minutes of your time
Why Use Automator Instead of Third-Party Apps?
- No additional software to install - it's already on your Mac
- Free - no need to purchase expensive video editing software
- Simple - works right from Finder with a right-click
- Customizable - you can modify the script to fit your needs
- No watermarks - unlike many free video merging tools
Creating Your MP4 Merger Automator Script
Follow these simple steps to create your own MP4 merger:
Step 1: Open Automator
- Open Finder
- Go to Applications
- Launch Automator (it looks like a robot with a workflow)
Step 2: Create a New Quick Action
- When Automator opens, you'll be prompted to choose a type of document
- Select Quick Action (or "Service" in older macOS versions)
- Click Choose
Step 3: Configure the Quick Action Settings
At the top of the workflow area, set the following options: - Workflow receives current: Files or folders - in: Finder - Optionally check Image to add a custom icon
Step 4: Add the Shell Script Action
- From the left sidebar, search for "Run Shell Script"
- Drag this action into your workflow area
- For Shell, select /bin/bash
- For Pass input, select as arguments
Step 5: Add the Shell Script Code
Copy and paste the following code into the script box:
```bash
Create a temporary file listing the inputs
temp_file=$(mktemp /tmp/file_list.XXXXXX)
Process input files
for f in "$@"; do # Add file to the list echo "file '$f'" >> "$temp_file" done
Create output filename based on current date and time
output_filename="$HOME/Desktop/merged_video_$(date +%Y%m%d_%H%M%S).mp4"
Use ffmpeg to concatenate the files
/usr/local/bin/ffmpeg -f concat -safe 0 -i "$temp_file" -c copy "$output_filename"
Clean up temp file
rm "$temp_file"
Show notification
osascript -e "display notification \"Merged video saved to Desktop\" with title \"MP4 Merge Complete\""
Open finder and select the file
open -R "$output_filename" ```
Step 6: Install FFmpeg (if needed)
This script relies on FFmpeg, a powerful multimedia framework. If you don't have it installed:
- Open Terminal
- Install Homebrew if you don't have it:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- Install FFmpeg:
brew install ffmpeg
Step 7: Save Your Quick Action
- Click File > Save
- Name your service something like "Merge MP4 Files"
- Click Save
How to Use Your MP4 Merger
Now that you've created your Automator script, using it is incredibly simple:
- Select two or more MP4 files in Finder
- Right-click (or Control-click) on the selected files
- Go to Quick Actions (or "Services" in older macOS versions)
- Select Merge MP4 Files
- Wait a few moments while the script processes the files
- Your merged video will appear on your Desktop, and Finder will open showing the new file
The files will be merged in the order they were selected. If you need a specific order, you might want to rename your files first (e.g., 01_clip.mp4, 02_clip.mp4, etc.).
Customizing Your Script
You can easily customize this script to fit your specific needs:
- Change the output location: Edit the
$HOME/Desktop/
portion to save files to a different folder - Change the output filename format: Modify the
merged_video_$(date +%Y%m%d_%H%M%S)
part - Add video quality options: Add additional FFmpeg parameters to control quality
Troubleshooting
If you encounter any issues:
- "FFmpeg command not found": Make sure FFmpeg is properly installed via Homebrew
- Files not merging correctly: Ensure all files are MP4 format with compatible codecs
- Script not appearing in right-click menu: Try restarting Finder or your Mac
Going Beyond Simple Merging
This basic script simply joins videos together without re-encoding. For more advanced options, you can modify the script to:
- Add transitions between clips
- Normalize audio levels
- Apply filters or effects
- Adjust resolution and bitrate
Conclusion
Creating a custom Automator script to merge MP4 files is a great example of how macOS's built-in tools can save you time and money. This simple workflow makes it easy to combine videos without needing expensive software or complicated workflows.
Give it a try with your own videos, and enjoy the simplicity of merging MP4 files with just a few clicks!
Note: This script preserves the original quality of your videos without re-encoding them, which means it works very quickly but requires that all input videos use the same codec and have similar properties. If you're working with videos from different sources, you might need a more sophisticated solution.
Need to download videos before merging them? Check out our YouTube downloader or Instagram downloader tools to get high-quality MP4 files from your favorite platforms.