Friday 30 March 2012

Recovering GOPRO video (on Linux)

Quick solution:  Go here. If the SD card is corrupt use Testdisk to recover the files.

Long solution:

The day before yesterday I travelled up to the China/Tibet border and stayed a night. On the way back I set my gopro to record the awesome valley road (and an unintentional jump over a ramp in the road) and I didn't stop to take a lot of pictures along the way because I had the video recording...

Now when I got to the guesthouse I started going through my photos and video, copied off all my videos from the SD card and then as per usual I deleted the videos and put the SD card back in the GoPro. It was after that I realised I was missing two of the videos. Not sure why they didn't copy, perhaps I ran out of space (using an SSD, it's likely) or I ejected before it finished copying or some stupid thing. Anyway, it was my fault they were gone.

Now the rest of this is technical mumbojumbo, hopefully it will help someone else with the same problem though.

I quickly got the SD card out and got to work trying to restore the videos. This is what I've spent the last 18 hours doing (aside from sleeping, although, I did wake up in the middle of the night and started another copy).

This guide is very helpful:

I used a few of the tools on that page: Sleuthkit, Foremost, Scalpel, Testdisk/photorec. Foremost wouldn't find the MP4 file, and Scalpel didn't have the MP4 header/footer configured anyway, so those tools were out. Photorec managed to recover random unplayable <1MB mp4 files, and a gpg file for some reason. So that didn't work either.

Testdisk however let me navigate through the file structure and copy the deleted MP4 files out... But they were unplayable! Figuring something was wrong with the tool I tried with Sleuthkit. But after a more complicated recovery the same file came out when compared to the Testdisk output  (verified by diff).

So still thinking it's a problem with the tools I went through several hours of trying different switches, other smaller apps, etc to try and get this video.

However it wasn't until I loaded some mp4 tools (MP4v2) that I figured out that I was actually dealing with a corrupt mp4 file, the undelete had worked successfully, it was just bad data it was recovering!

After lots of reading forums and various sites going nowhere I stumbled on this site:

It seems the corrupt mp4 files from the GoPro are fairly common, I haven't had one before though.

I downloaded the perl script from that site and in the first go it extracted the video from the deleted file I had acquired from testdisk! Actual Success! The audio isn't extracted but that's ok, I might be able to modify the perl script to get that out too if I really want it. I'm just glad I finally have the video of riding through that awesome valley!

Now I can finally get to processing the photos from the storm in the valley, riding through the valley, being followed by someone at the Nepal/China/Tibet boarder, the video of the valley and my first motorbike jump, and also the storm last night and the first view of the Himalayas!


  1. Saved my life, thanks very much!

  2. Thanks for your post Ryan, it helped me in my first steps to recover my lost videos. But, I also wanted to recover the audio from my videos.

    That's why I developed a small script capable of recovering lost/deleted videos from the SD Card. It can be found here :

    This script really recover the complete video and doesn't require to run the Perl script from "tchiers", because the video header used will be the original one !

    1. Excellent! I'll give it a try tonight, I never did recover the audio off these files. I was going to look at it at some point, honest!

    2. THE AMRT tool worked a treat Thankyou. I had backed up the sd card using dd and recovered the files with photorec but the videos did not play. Thanks again it was really nice to have the videos back.

  3. I recover my gopro from here, same use. save my life too. just share another solution that hope can help

  4. I tried AMRT mentioned here, but it did not succeed. However, on AMRT's site I found a trick to make a card's partition image with the use of ddrescue.
    I tried to scan the produced partition image with the latest (static) PhotoRec and it did an excellent job to me without using any additional scripts and tricks. I just mistakenly formatted my GoPro HERO4 Black card with a 30 GB of valuable video and wrote a timelapse on top of that. Despite the fact PhotoRec does not list MP4 in its formats in the settings of the program (only MP3 is there), it does list it on the official site and simple run without touching any setting did the excellent job for me. All videos were restored, with audio and metadata intact (with a date and time when shots were taken etc.). Only filenames were missing, but that is a not a big deal at all.
    Give PhotoRec a try.

  5. Good solution. I just want to share another solution which helped me last time.