Zum Inhalt springen

untrunc and ffmpeg: Open-Source Video Repair and Where It Stops

untrunc and ffmpeg are free open-source tools for video repair — and good enough for plenty of standard cases. Where do they hit their limits, and when is a specialized tool worth it?

J

Jonas Becker

Codec-Research · Tech Writer · May 19, 2026 · 5min read

ffmpeg and untrunc are the two most important open-source tools for video repair. Both are free, both are powerful — and in many cases they’re enough. But they have specific limits that become genuinely relevant with modern professional codecs.

This article is an honest technical look at both tools — what they can do, where they fail, and what actually justifies the jump to specialized tools.

untrunc-anthwlock: what it can do

untrunc is a CLI tool originally written by Federico Ponchio — a response to the classic “moov atom missing” case. The maintained version is the fork untrunc-anthwlock (on GitHub).

The idea: you have a broken MP4 (ftyp + mdat, no moov) and an intact reference MP4 from the same camera. untrunc analyzes the reference, extracts the codec parameters and the container structure, then scans the mdat of the broken file and synthesizes a new moov atom.

# Installation on macOS
brew install ffmpeg
git clone https://github.com/anthwlock/untrunc.git
cd untrunc
make FF_VER=4.1

# Running it
./untrunc reference.mp4 broken.mp4
# Output: broken_fixed.mp4

Key flags:

  • -n — non-interactive (otherwise the tool asks whenever it’s unsure)
  • -s — skip unknown sequences (often needed with Sony XAVC, Canon Cinema)
  • -V — verbose (shows what’s happening; good for debugging)

Where untrunc works well

H.264 MP4 with a missing moov and a matching reference: Success rate ~85%. You get a repaired file that plays and usually shows no picture problem.

GoPro HERO up to HERO10 (H.264 models): Works reliably. HERO11+ (HEVC) is tricky — see below.

Standard iPhone videos before the 12 Pro (H.264 in MOV): Very good.

Generic camcorder footage, webcam videos: Solid success rate.

Where untrunc fails

Three systematic problems:

1. HEVC 10-bit often gives you picture-less files

With HEVC (H.265) there are two container variants:

  • hvc1: SPS/PPS/VPS sit exclusively in the hvcC box (out-of-band)
  • hev1: parameters can also sit in-band in the bitstream

untrunc doesn’t handle this reliably — with iPhone Cinematic, GoPro HERO11/12/13 in HEVC 10-bit, DJI Avata 2 — all modern HEVC sources — you often get a file that opens but stays black. The container is there, the codec header is reconstructed wrong.

More background: Understanding the MP4 container — the hvcC box

2. Audio drift is not corrected

untrunc reconstructs the container but doesn’t actively deal with audio sync. With Sony XAVC you almost always get a 480ms audio drift back, which you then have to fix manually with ffmpeg afterward.

# Fix drift manually (480ms audio ahead of picture → shift 480ms backward)
ffmpeg -i broken_fixed.mp4 -itsoffset 0.480 -i broken_fixed.mp4 \
  -map 0:v:0 -map 1:a:0 -c copy clean.mp4

Fine for simple cases. With multi-track audio (FX3 with 4 PCM tracks) it gets tedious — you have to measure the offsets per track and apply them one by one.

Details: Fix audio drift in your video

3. DiskDrill-recovered files with a corrupt uuid

When the uuid box at the start of the file is mixed together from adjacent sectors (typical DiskDrill damage), untrunc takes the uuid bytes at face value and does a repair based on wrong profile assumptions. The result is usually a garbage picture or wrong framerate.

untrunc has no way to configure “ignore uuid and derive the profile from the mdat frame structure.” It’s conceptually too generic.

More: Repair DiskDrill-recovered video

ffmpeg: the Swiss Army knife

ffmpeg isn’t primarily a repair tool — it’s a generic multimedia toolkit. But it has a few repair tricks.

Trick 1: Error detection during decode

ffmpeg -err_detect ignore_err -i broken.mp4 -c copy fixed.mp4

With an intact moov but corrupt frames, ffmpeg copies the healthy parts through. With a missing moov, ffmpeg bails out immediately — no repair path.

Trick 2: Remux without re-encoding

ffmpeg -i broken.mp4 -c copy -movflags faststart fixed.mp4

With light container corruption, a simple remux can already help. Often makes sense after untrunc, to clean up the final container.

Trick 3: HEVC tag correction

ffmpeg -i broken.mp4 -c copy -tag:v hvc1 -bsf:v hevc_mp4toannexb fixed.mp4

With a hev1/hvc1 tag conflict (very common after a tool has repackaged the file) this can fix the playback problems.

What ffmpeg can’t do

  • Reconstruct the moov atom — no NAL-unit scan function
  • Measure audio drift automatically — you have to know the drift yourself
  • Reference-based repair — doesn’t exist
  • Codec-profile detection with broken headers — no

ffmpeg is a decoder/encoder, not a repair tool. When the container is fundamentally broken, ffmpeg is powerless.

Direct comparison

TaskffmpeguntruncHaven
Skip corrupt frames★★★★★☆☆☆☆☆★★★☆☆
Reconstruct moov atom☆☆☆☆☆★★★★☆★★★★★
Reference-based repair☆☆☆☆☆★★★★☆★★★★★
HEVC 10-bit correct★★★★☆★★☆☆☆★★★★★
Audio drift automatic☆☆☆☆☆☆☆☆☆☆★★★★★
GUI / preview☆☆☆☆☆☆☆☆☆☆★★★★★
Pricefreefreeper repair
Learning curvehighmediumlow

When are open-source tools enough?

When:

  • You’re technically experienced (CLI-comfortable)
  • You’re repairing simple H.264 files
  • You have time for trial and error and manual drift correction
  • You don’t want to spend money on a commercial license

Then ffmpeg + untrunc is a reasonable stack. Success rate when used correctly: 60–75% on simple cases.

When is a specialized tool worth it?

When:

  • You work with modern professional codecs (HEVC 10-bit, XAVC-I, ProRes)
  • You regularly have to repair files (wedding photographer, editor)
  • Audio drift matters (anything with speech, music, dialogue)
  • You can put a dollar figure on your time

For a freelancing wedding photographer with 10 broken files a year, the hours of trial and error with open source add up fast — 20–30 hours — and at an 80-EUR hourly rate that’s 1600–2400 EUR of opportunity cost. A 10–30 EUR Haven license per repair is a lot cheaper than that.

My technical verdict

Open-source tools are fantastic for the 60% of easy cases. They’re robust, transparent (you can read the code) and free. They’re also a good foundation to learn on — once you’ve understood untrunc, you understand the container structure intuitively.

But: they weren’t designed for the modern professional codecs. The HEVC profiles, the audio-sync pipelines, the DiskDrill edge cases — all of that came up only in the last few years. Open source is rarely maintained at the pace a commercial tool with a focused team can manage.

Anyone working seriously with modern footage won’t get around specialized tools — or has to budget the learning curve and time for manual workarounds.

Try Haven for free → — if you want to see how a specialized tool stacks up.

About the author

J

Jonas Becker

Codec-Research · Tech Writer

A computer-science background with a focus on video containers and stream parsing. Writes Haven’s deep-dives — from HEVC NAL-unit structures to Dolby Vision RPU metadata.

Specialty · HEVC · ProRes · Container standards · NAL-unit analysis

Newsletter

When a new repair guide goes up — one email. Monthly at most.

No marketing sequences, no promo blasts. Just a heads-up when a new pillar guide, codec deep-dive or honest comparison goes live.

No spam. One-click unsubscribe from every email.