How to restore GoPro MP4 corrupted or truncated file ?

Note : this article is a rough translation of the original french article, please let us know about any error (gopro.hacks@gmail.com)

Maybe you already experienced your GoPro HD to stop filming, for one reason or another (runned out of batteries, crash...).
Thus, you may have noticed once home that some file was unreadable. This happens while the connection between camera & SD card is cut.

If the file has a normal size though, you will read the following lines with great interest.

In fact, the camera just didn't have the opportunity to write a correct "index" file on the MP4.
These "indexes" are necessary for a player to decode the video stream from your file.

The GoPro has a function that is pretty badly documented to avoid this kind of disagreement, so let's talk about it here.
It's called the "SoS function".


If you have some doubt about your last file being possibly corrupted, put the SD card in its slot (if necessary) and power on the camera.
If the GoPro's LCD screen displays "SoS", this means the camera found the file to be truncated and will attempt to repair it.
To allow this, you simply have to push any of the button in order to run the process. The GoPro will be able to recover the file in most cases, by writing a new header (the moov atoms of the MP4 file).
When the red led stops blinking, the repair is done.

Of course, avoid any work on the file before trying this restauration step.


If this fails :please be aware it is sometimes possible to recover the only video stream (see free script above) of the MP4 file after all.
There is also a paying service that is able to recover most of the time both video AND audio (see "commercial services" paragraph above.
First condition : that the file actually does have video information (if the file is empty, there's nothing to work on ! Please verify the file size).


Two different technique may work : rewriting of the index, or copying each of the video frame, one by one.

Let's talk about one solution that use index rewriting by recreating the missing moov atoms of the file.

A Perl script has been written by Tchiers to achieve this (GoPro.Hacks wrote a little batch file to make it simple to use). You will find the ZIP archive HERE.(BETA version with NTSC/PAL support, not tested)
old version, only NTSC
This is only expected to recover the VIDEO stream (no audio).
Let's detail the way you will proceed (please note this is dedicated to windows users, but the Perl script contained in the package may be run under any other OS -mac, linux- where Perl 5.8 or above is hosted) :
  1. Download and install Perl version 5.8 or above.
  2. Create a folder
  3. In this folder, let's copy the content of the fixen.zip archive. You should find one file called "fix.pl", which is the Perl script used to do the work, and a file called "run_me.cmd" which is the batch command that will help you to use the script easily. Do not download from any other source to insure these are virus-free.
  4. Copy your dammaged file into this same folder you created (for the example, we'll call this file 'video.mp4', and we will suppose it was filmed in R3 mode).
  5. Double-click on the "run_me.cmd" file.
  6. A new command-line window will pop-up. You're just requested to answer some very simple questions:
    • write down the complete name of the corrupted video file, including it's extension (video.mp4 in our example)
    • set the mode used for filming (r3 in our example, aka the 720p). If your camera is set on NTSC, you will enter ntscr3, if PAL : palr3 and so on...
    • for the first try, enter 0 as the compensation value. You will modify this parameter only if the resulting file does not play smoothly.
  7. The Perl script will then try to recover the video stream. The resulting file will be renamed with the original file name + the extension '.restore.mp4'.
    Check with VLC player  that the video stream has been well restored.
    If you can see the video stream but that it does not play correctly, run the batch again but now enter different compensation values (1 at first, then 2 if there's still some problem...) until the video stream looks good.
    You should meet some difficulties to use advanced playing function (such as fast forwarding the video). This is due to the fact that the file is not totally complete and well indexed.
    Re-encoding the file is therefore a recommended option.
For Mac users, here is the source codeo of a patch tool called recoverMP4.
It will allow you to rebuild the description of GoPro files. Please note this is only a SOURCE, originally dedicated to one single file. This won't work, as it is, for a general purpose and you will have to adapt the code to your very own file caracteristics (size, framerate, etc.) Some knowledge is therefore required.

COMMERCIAL SERVICES

Last, if you didn't succeed in recovering your video file and if this one looks important to your eyes, or if you absolutely need audio, note that there exists a commercial service specialised in MP4 recovering.

In the most difficult cases, they do a manual repair of the video, which may take some time.
We could recommand this address : videofilerepair@gmail.com which we already worked with. They restaured for us both video AND audio from a damaged file.

After a first message to detail our request (shooting mode, duration...) you will receive an answer with a quote.

If you find the rate acceptable, you then send the damaged  file for examination. In return, you will receive a message telling you whether the file may be repaired or not, and if it is, you'll be able to download a short video sample of the repaired video for you to evaluate the quality you may expect from the repair.

If everything is Ok to you, you will receive payment instructions. Once this done, you will receive a link back to download the repaired video.

Note that reparation duration may vary quite a lot, according to the file size and the technician availibility.



.