Repairing a broken mp4 video using untrunc – “moov atom not found”
Uncategorized 0 CommentsThe problem
VLC reports:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f9030c5ea00] moov atom not found
Ffprobe and ffmpeg reports:
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55c2c17aa600] moov atom not found
videofile.mp4: Invalid data found when processing input
The details
The moov atom
is basically and index and technical description to the mp4 file, as it contains info about the whole video it can only be written once the video is complete, so it is usually located at the end of the file.
If the recording device loses power, crashes, runs out of disk space, or a download fails for any reason, the file gets broken.
Unfortunately the moov atom
is unique to every video, even the recorders/encoders have different parameters.
This can affect GoPro videos, iPhone recordings, live stream recordings, etc.
The (possible) solution
There is a tool called untrunc, but I recommend the fork by anthwlock as it has several improvements over the original (better performance, easier build and better compatibility).
It works by analyzing a video that was recorded by the same recorder/encoder (“good.mp4” in the example) then tries to recreate a moov atom
for the broken video (“broken.mp4” in the example) based on that.
All you need to do is download the code, compile it, then run:
./untrunc good.mp4 broken.mp4
This has worked for me several times but there are detailed description in the repository so check that out if you need more info.
Note: the “good” video should be recorded with the same settings (i.e. same video mode, slow motion, etc.) with the same version of the same software as the broken one.