← All posts
·7 min read

How to build and use untrunc on a Mac

Publisher of DataRecover Pro

untrunc is the free tool people reach for when a camera clip won't play because the recording was cut off. Give it the broken MP4 or MOV and a healthy clip from the same camera, and it writes a new, playable file. It is open source (GPL-2.0), it runs entirely on your Mac, and it has rescued a great deal of footage.

What it doesn't have is a Mac installer. The project publishes ready-made builds for Windows only, and as of November 2026 Homebrew has no untrunc formula, so brew install untrunc fails. On a Mac you compile it yourself. That is a handful of commands, and the ones below are the project's own, taken from its README and its macOS wiki page as they stood on 16 November 2026. We ran them the next day on an Apple Silicon Mac, and what happened is noted at each step.

Which untrunc

There are two. The original is github.com/ponchio/untrunc. The one to use is the fork at github.com/anthwlock/untrunc, which describes itself as an improved version of the original: more than ten times faster, low on memory, able to handle files over 2 GB and to skip over bytes it doesn't recognise, with support for GoPro and Sony XAVC footage. It is still being worked on; its latest commit when we checked was dated 1 November 2026.

Both need the same thing from you, and the README puts it plainly: another video file which isn't broken, ideally from the same camera. If it isn't from the same camera, it says, the chances of a fix are slim.

Before you build: get the reference clip

untrunc learns the codec settings and the track layout from the healthy clip and uses them to read the broken one. So the reference should match in every way that changes those: same camera, same resolution and frame rate, same codec and audio setting.

If you don't have one, make one. Put a card in the camera, record ten seconds in the same mode, and stop the recording normally. Then copy the broken file off its card to your Mac, and keep the original untouched. Work on the copy.

Build it against Homebrew's ffmpeg

untrunc is built on ffmpeg's libraries, and the README's macOS route takes them from Homebrew. You need Apple's command line tools (xcode-select --install) and Homebrew (brew.sh). Then, in Terminal:

1. brew install ffmpeg yasm

2. git clone https://github.com/anthwlock/untrunc && cd untrunc

3. CPPFLAGS="-I/opt/homebrew/include" LDFLAGS="-L/opt/homebrew/lib" make

The paths in step 3 are where Homebrew lives on an Apple Silicon Mac. On an Intel Mac it lives in /usr/local, so use /usr/local/include and /usr/local/lib; we did not test on Intel. When make finishes there is a program named untrunc in the folder. It is not installed anywhere else; you run it from there as ./untrunc.

On our Mac step 3 took eight seconds and ended with four compiler warnings and no errors. A program built this way loads Homebrew's ffmpeg every time it runs, so leave ffmpeg installed.

The ffmpeg version matters

This is the part that trips people up. The README says that in certain cases a specific ffmpeg version is needed, that untrunc works well with ffmpeg 3.3.9, and that versions above 8.1 can go wrong, because untrunc reaches into a part of ffmpeg that changes between releases. Homebrew's ffmpeg was at 9.0.2 on the day we checked, which is above that line. So a build against Homebrew's libraries may compile and still misbehave.

Ours didn't. We cut an H.264 clip and an HEVC clip off at 70% of their length and ran the 9.0.2 build on both. It repaired each one, and the files it wrote were the same, byte for byte, as the ones from the two builds described next. Those were clips encoded on the Mac, not footage from a camera, so the README's warning still stands. If the Homebrew build stops with an error, or writes a file that won't play, the next step is the fix.

The project's answer is to let its Makefile fetch and build the ffmpeg it wants: make FF_VER=3.3.9 in the same folder. That downloads ffmpeg's source from ffmpeg.org and builds a cut-down copy inside the untrunc folder, without installing it on your Mac. The untrunc program from step 3 is replaced by one that carries its own ffmpeg and no longer needs Homebrew's. On our Mac this took about a minute, and so did make FF_VER=8.1, the newest version the README treats as safe. Old ffmpeg releases don't always compile on a newer system, so if 3.3.9 fails on yours, try 8.1.

If neither build works, the project's macOS wiki page takes a third route and runs untrunc in Docker. With Docker Desktop installed: docker build -t untrunc . in the source folder, then docker run -v ~/Movies/:/mnt untrunc /mnt/ok.mp4 /mnt/broken.mp4. It isn't a native build, but it sidesteps the Mac toolchain entirely. This is the one route we did not run.

Run it

The healthy clip goes first and the broken one second: ./untrunc /path/to/working.mp4 /path/to/broken.mp4. Dragging a file from Finder into the Terminal window types its path for you. untrunc works through the broken file and writes the result as a new file beside it, with _fixed.mp4 added after the whole name: broken.mp4 becomes broken.mp4_fixed.mp4.

A few options are worth knowing. -v prints a great deal more detail (tens of thousands of lines for a 45-second clip), which is what the project asks for if you report a problem. -s steps through stretches of data untrunc doesn't recognise, for when it stops part-way. -sv stretches the video to match the length of the audio when the two drift apart, and is marked as beta. -dst followed by a folder sends the output somewhere else. Running ./untrunc with nothing after it prints the whole list.

Then check the result in QuickTime Player, which is strict about structure: if it opens the file and you can scrub to the end, the index is sound. Listen for sound that drifts away from the picture, the usual sign of a reference that didn't quite match.

If you would rather not build anything

DataRecover Pro repairs the same kind of file in an app. For H.264 and HEVC clips, which is what phones, action cameras and most mirrorless cameras record, its repair engine rebuilds the index from the frames themselves, so a reference clip helps and isn't required. It also covers the step before untrunc: if the clip was deleted or the card was formatted, the scan finds it first.

Scanning, preview and the repair assessment are free and need no account. Repairing and saving the file needs a license. For a clip under 256 MiB you can find out what is broken without installing anything: the free MP4 and MOV checker reads it in your browser. The two tools are compared side by side in untrunc vs DataRecover Pro, including the case where untrunc is the better choice. Download DataRecover Pro.

When this won't work

untrunc cannot work without a healthy clip, and a clip from a different camera or recording mode usually isn't good enough. It repairs a file you already have: it doesn't search a card for a clip that was deleted, so recover the clip first. It can't return footage that later recordings overwrote; no tool can. A ProRes MOV with no index needs a reference that matches exactly, covered in recovering ProRes and 4K MOV after a recording stopped. And if the card is throwing read errors, image it before you copy anything off it, and work from the image.

Lost a file? Get it back.

Scan and preview for free. See what's recoverable before you buy.

Download for macOS