Menu
Cart

Damaged GoPro File Repair Utility (HERO2)

Posted by Mark Kirschenbaum on

This is a re-post with permission from GoProUser Forums on how to repair a damaged MP4 file from a GoPro camera that was shutdown improperly. tchiers was kind enough to allow us to re-post this here since GoPro Forums requires you to register. For questions about this utility please see the original forum at this link. After I run a GoPro file through this utility I do do some other things, please read my full repair post here

FROM tchiers:

Like alot of posts I see here, I had the 'SoS' problem with some of my video files. I didn't know about the 'press any button' trick at the time, and the camera didn't fix the files automatically later, so I was left trying to recover the video after the fact.

I examined the contents of the files and it was pretty clear that I had the raw video data preserved, but no header to allow the reading of it. With some known good sample files and a copy of the mp4 container spec, I was able to figure out enough to reconstruct the headers. 

So I wrote a perl script to fix my damaged and unplayable video files(attached). 

Edit: Here are more explicit instructions.

If you don't already have perl v5.8 or later on your computer, you will need to install that first.
ActiveState makes a good free version and you can get it here: http://www.activestate.com/activeperl/downloads
I also recommend installing VLC for video playback. You can get it here: http://www.videolan.org/vlc/download-windows.html

Once you have installed perl, you can confirm it is installed correctly by opening a command prompt window and giving the command:

perl -v

You should see something like this:

This is perl 5, version 12, subversion 1 (v5.12.1) built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)
...

To fix your file, I recommend crating a temporary directory to work in. C:\temp will do nicely
Copy your damaged video file(s) into this temp directory.
Download the .zip file attached to this post and unzip it. There is a single perl script (.pl) file inside.
Copy this perl file to the same temp directory as your videos.
Open a command prompt widow
cd to your temp directory (e.g. cd \temp)
Run the script with this command:

perl fix_header_v3a.pl <file_to_fix> [-options]

Replace <file_to_fix> with the name of the damaged video file you are trying to repair
Replace [-options] with any of the following options:

-reso Resolution      Sets the resolution mode the corrupt file was shot in.
                      Defaults to 720P30 'r2' if not specified
                      Valid values are 480p60, 720p30, 720p60, 960p30, 1080p30, r1, r2, r3, r4, or r5
-ctts N      Sets ctts offset to N. Defaults to 0 if not specified
             Use this to correct jerky playback in reconstructed video due to out-of-order frames
             Valid offsets are 0-2 for 720p30 'r2' & 960p30 'r4'; 0-5 for 720p60 'r3' & 480p60 'r1'

For example, if your damaged file is GOPR0001.mp4 and you took this file in 720P60 'r3' mode, you would enter

perl fix_header_v3a.pl GOPR0001.mp4 -reso r3

If all goes well you will see output that looks like:

Attempting to fix GOPR0001.MP4

Found frame 000252 at 0083b65b
Opened file GOPR0001.MP4.restore.mp4 for writing

Found 252 (fc) frames, or approx 4s of video at 60fps
   min size e2d, max size 30c4c
   from 8008, to 839b5c
Calculated header size of 0x8000
Using ctts offset of 0
Using 1280 x 720 @ 60 fps
Copying  frame 000252...
Done.

The script will create a new file with the same name as your damaged file with ".restore.mp4" tacked on the end. You should be able to open and play this file in VLC. 

If the video plays back but appears very jerky due to out of order frames on playback, run the recovery script again using a different -ctts value until the recovered video looks right. 

There will be no audio in the restored file, as the script is not smart enough to find lost audio at this time.

 

Please note:
This is quick 'n' dirty and not extremely robust code
It's non-destructive; it will copy the old data into a new file, so be sure to have plenty of disk space wherever you run it
It makes no attempt to recover the audio. The raw audio data is preserved, but I don't know enough about Mp4/AAC to recover it.
It will not help at all with filesystem errors (e.g. you can't move or copy your file)

Here is the utility tchiers created: fix_header_v3a.zip

This utility gets you half way there, to get it 100% to get the file read for editing I recommend a few extra steps recommended here.


Share this post



← Older Post Newer Post →

Hypoxic Products