Those GoPro HERO Videos that Cannot Could Not be Repaired
Once upon a time, there was an action camera called GoPro. It quickly became the top seller of its category, with 9 millions cameras shipped since 2009, and made its CEO a mad billionaire.
And since action cameras have a rough life, with no surprise did we start receiving several GoPro repair requests every day.
GoPro corrupt footage was routinely repaired, using deep parsing and re-indexing techniques.
One Day…
One day, we received a damaged GoPro file that couldn’t be cleanly repaired. Re-indexing seemed to work fine, and repaired videos were playable, but they were full of glitches, and audio was repeated every couple of seconds, like a mad echo effect.
At first we didn’t pay a lot of attention to this, we just said to the customer that the video could not be cleanly repaired due to presence of “alien data” inside the file. Alien data is material that should not be in the damaged file, and that makes re-indexing more difficult or even impossible. This is a bit like waste recycling that can only be efficient if waste has been properly triaged beforehand.
We were not wrong about “alien data” contamination, but not for the expected reasons… A few days later we received one, then two more damaged videos from different customers that were having the exact same symptoms:
- Damaged files preview perfectly with Treasured.
- However, after repair, it was a mix of clean and garbled video, with audio repeating (like echo) every two or three seconds.
At this point I considered having discovered a new failure mode, and I guessed that it was probably a side effect of how new GoPro cameras operate.
Cracking New GoPro
The most intriguing fact about this failure mode is that audio repeats, so we started our investigation with audio.
After close examination, I noticed that not only audio was repeating, but video as well! The only difference is that secondary video wasn’t directly visible, indeed the glitches inside repaired video are our secondary video stream. So we have a camera that records two streams at once, both with same audio but incompatible video.
Does it sound familiar?
It didn’t for me at first, but when I read the list of changes in new GoPro firmware and cameras, everything became clear…
LRV for Low Res Version
It turns out that GoPro camera now records an LRV clip at the same time as the HD clip. The LRV file is a lower resolution version of the video recording used for preview purposes on the phone and tablet GoPro applications (less data to transfer wirelessly to the device running the application, and less decoding raw power required as well).
During recording, your GoPro camera produces two streams of videos, one high resolution (represented by big orange images on illustration, and one low resolution, whose volume is one fourth to one tenth, hence the small blue images.
The Locker Room
Now let’s figure out what happens when the camera writes the two streams on the SD card. In computers, but also in phones and cameras, a program called “file system” is in charge of storing data and keep track of where it is stored to be able to read it later.
You can think of the SD card as a locker room, with thousands of lockers, all of the same size. People who want to store their stuff give it the person in charge, the file system, who will put it in one or several lockers and keep track of what goes where.
During recording, every second the GoPro guy comes to the locker room with new boxes that he hands over to the file system: 4 orange boxes, that fill 4 lockers, and 4 small blue boxes, that fit in one locker. To go faster, the file system fills the lockers in rows, so orange and blue boxes are interleaved.
Disaster Strikes
Unfortunately, before our file system could write in the registry where boxes have been stored, fire alarms suddenly start shrieking, and everyone leaves the building. A few minutes later, people is authorized to go back to work, but our file system no longer remember where video has been stored. Our GoPro is desperate… and calls SoS!
Cleaning up this Mess
Finding footage is easy, just open all the lockers, put all items together, and pray. This is what Data Recovery utilities do. Unfortunately, this won’t work because besides fragmentation, we have LRV data interleaved with HD video, that will cause glitches and echoing audio once fixed.
As you have guessed, we now have two problems:
- Separating LRV from HD video
- Re-indexing video
Triage
There’s no such thing as orange and blue data. Both streams contain H.264 video and AAC audio and are nearly indistinguishable. Yet we need to surgically separate them. Cutting just one byte off would generate glitches in several frames.
Fortunately, two things makes triage possible:
- Streams are mixed in locker-sized chunks. Cuts can only happen every 131072 bytes exactly, at discrete locations.
- Every H.264 frame starts with a pattern that informs of its exact bytes length, so we can verify whether it’s in one piece – or – whether 131072 bytes of “blue data” are contaminating the frame.
Combining those two hints, I have managed to remove LRV from the raw data. Now we are back to the normal situation of a corrupt video in need of re-indexing.
Amazing: Kayak Footage Restored!
The final step is to re-index the cleaned – yet still corrupt – raw file. Needless to say, when you have cracked a new failure mode like this one, this is a lot of excitement the first time your repair program finally cranks out clean video.
The first video that I have managed to fix shows some guys paddling in kayaks, so I have decided to call this feat: to pull a kayak
Frame from repaired clip, courtesy of Gordon Scott
If ever you face a corrupt video problem with your GoPro, even if it’s not a “kayak”, just send us a request through Treasured and we will do the paddling for you. 🙂