How can I repair a broken 3GP/MP4 file without a moov header?

I was recording audio two days ago and my phone suddenly died while doing so. I used MP4repair and a short clip of sound could be heard and they would be charging $80 to recover it. I thought it was too much and I don't even own a credit card, so I ruled out that possibility.

Apparently, the moov header is missing for this file. Is it possible to generate a moov header for this recording? Or better, is it possible to recover this file without having to pay those 80 Dollars?

So far I know that it is AAC audio inside a 3GP container.


Solution 1:

If you have a Debian-based Linux, you can use untrunc. Open up a terminal window and run the following commands, one by one:

sudo apt-get install libavformat-dev libavcodec-dev libavutil-dev
cd ~
wget https://github.com/ponchio/untrunc/archive/master.zip
unzip master.zip
cd untrunc-master
g++ -o untrunc file.cpp main.cpp track.cpp atom.cpp mp4.cpp -L/usr/local/lib -lavformat -lavcodec -lavutil
chmod +x untrunc

Now, you need:

  • the broken file
  • a correct file – you just need a working file that you obtained from the same device

Put both into the untrunc-master directory. Then, run:

./untrunc correct.3gp broken.3gp

This will output a bunch of info, and it should give you a broken.3gp_fixed.mp4 output file.