Open gavia opened 2 years ago
Interestingly, the corrupted file itself contains a valid moov atom. But it looks like some junk(?) data got injected to certain places, leading to an (from the original moov unaccounted) offset for the following frames.
It is unclear to me whether those junk-sequences always start at the end of another healthy frame, or if they span across frames. However, assuming the second hvc1 frame is contained fully, the first unknown sequence is exactly 131072 (= 2**17) bytes long. This makes me think that these junk-sequences might got inserted in some "controlled" way, however the lengths of following junk-sequences are not that regular (maybe because they span multiple frames).
What I also found interesting is that the mp4a frames often contain sequences of low-entropy data like
"2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D 2D" // "------------"
"D2 D2 D2 D2 D2 D2 D2 D2 D2 D2 D2 D2"
"5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A 5A" // "ZZZZZZZZZZZZ"
"A5 A5 A5 A5 A5 A5 A5 A5 A5 A5 A5 A5"
"69 69 69 69 69 69 69 69 69 69 69 69" // "iiiiiiiiiiii"
"96 96 96 96 96 96 96 96 96 96 96 96"
I am unsure about the meaning of those, but 1. the healthy file does not contain those, 2. maybe it (somehow) indicates that an audio-frame is a duplicate (since the recovered file seems to often have audio sequences (~1-2s) repeated)
Since I am not sure of the meaning of the junk-sequences, I can't say whether perfect recovery is (theoretically) possible or not. If you find other tools which are able to produce better results, please let me know. One could for example try the demo of GPR.
In caf8cbb0ac160cb320d2a3884ef6bc81becd7d2a I restricted the patterns for fdsc
and hvc1
tracks after unknown sequences. It should improve the recovery of your files a bit, but repeated audio sequences and some video glitches remain.
Thank you for investigating. I had come across GPR before but because I don't have a windows computer, I haven't tried it. I think it's time for me to setup a VM and give it a go.
Some further information/thoughts: the corrupted video file(s) were all recovered using PhotoRec. What initially happened was that the GoPro suddenly started beeping during recording and then turned off. When I got home and looked at the memory card, it was as if it had just been freshly formatted, however strangely enough the files that had been trashed but not actually deleted still remained in the trash folder. This led me to believe that an error during recording had essentially wiped the partition information and/or scrambled the data, but had not completed a "fresh" format.
I created an image of the SD card (128gb) using TestDisk and started trying to recover the files using a variety of software. PhotoRec was the one that gave me the best results. The low resolution JPG files were recovered perfectly fine, and all of the high and low resolution videos were recovered but none of them would play except for the one that I sent you which included the moov atom.
On the image itself I did some deeper analysis in a hex editor and was able to find all (I think) of the moov atoms in tact, but none of them appeared directly after the mdat atoms. Further, there was a LOT of garbage or other data in between the end of the mdat atom and beginning of moov atoms, and I wasn't sure which mdat atom matched which moov atom. There was also a lot of structured data directly before every single moov atom so I wasn't sure if I could simply take the beginning of a moov atom and piece it to the end of an mdat atom.
This is how I came to untrunc, as I figured it might be easier to recreate the moov atoms for the entire mdat atoms rather than match them up as described above.
Next steps I'll try GPR, and perhaps come back to matching the moov atoms with the mdat atoms manually, but as a last resort as that will require much more work, unless you know of software that can try to do that automatically from an img file?
Let me know if you'd like to see any of the other corrupted videos, either low quality (which are closer to 250mb) or high quality (most of which are 4gb) - there be more hints in those as to what happened I guess?
By the way, do you know of any software that can look at a moov atom and tell me the length/size/other information that it holds (does this question even make sense?) It might help me in piecing it back together later, rather than complete trial and error.
I guess the filesystem of the SD card (ntfs?) did not store your files (completely) sequentially. So those sequences of junk-data could be data from other files. In that case it could be worth a try to recover the filesystem itself, since it would know exactly what (logical) file is spanned across what physical blocks. Maybe testdisk can already do this, otherwise there might be specialized software for the specific filesystem.
were recovered but none of them would play except for the one that I sent you which included the moov atom
You mean the broken 400mb one, right? Do I understand it correctly that PhotoRec put the moov atom at a sensible place, or at least edited the mdat's length? Because I would not expect the moov to align with the mdat by "accident", since the original mdat length was referencing offsets in the logical file, not on the physical disk.
There was also a lot of structured data directly before every single moov atom
Perhaps this is from the "gpmd" track, which (I believe) store data like GPS or acceleration. In that case it could be a normal part of the mdat.
so I wasn't sure if I could simply take the beginning of a moov atom and piece it to the end of an mdat atom.
In principal yes, but you might have to adjust the length of the atoms a bit, since the original length assumes a sequential file.
Next steps I'll try GPR
Let me know about the results!
unless you know of software that can try to do that automatically from an img file?
I don't know of any. I would probably write a python script. But I wouldn't be too confident in that the result is any better than the corrupted 400mb, even if the correct mdat and moov are matched up.
Let me know if you'd like to see any of the other corrupted videos, either low quality (which are closer to 250mb) or high quality (most of which are 4gb)
Sure, why not! For example I wonder if the first unknown sequence with length 2**17 also occurs in other files. Maybe there even is a regular pattern in which those junk-sequences get placed into the file. However I wouldn't have too high hopes about that. Feel free to send me both quality levels. Maybe also one file two times, once from PhotoRec and once manually extracted from the disk image.
do you know of any software that can look at a moov atom and tell me the length/size/other information that it holds
I assume you mean the length of the individual frames. In that case, untrunc -d
can do this!
Also I think untrunc -ia
dumps the first n entries of each relevant atom (stsz, stco, ..)
I once wrote a simple atom parser in python, maybe it is useful to you. It currently is hard coded to dump the ctts
table in the second track.
@gavia Any news? Have you tried GPR?
@anthwlock So sorry for the late reply, I've been traveling recently. I tried GPR and it was mostly successful. Although some of the videos were still a bit choppy, most of them came out perfectly. It must be that the GoPro saves the files in a way that is non-standard but GPR can somehow re-create that. I need to do a proper review of all of the footage (there was a lot) when I return from overseas to see the full extent of the recovery/damage but from the few that i checked they were pretty good.
I can still send you some of these files (including recovered ones) if you want to look in more detail but it will need to be in late January when I am back and have access to my footage.
Hi, I'm trying to recover about 20 videos from my GoPro Hero 9 which unfortunately all become corrupted when the GoPro suddenly powered off during recording. I have been able to successfully restore most of each video by using -s, however there are numerous points inside of each video where the correct codec could not be found. Below is the output when using ffpmeg 3.3.9. When using -s, there are many many instances of
Warning: Codec::was_bad_ = 1
I initially tried this on the latest ffmpeg, where there were far fewer instances of the above warning, but they were being skipped.
Are you able to help at all? I'll send you the videos - I have chosen a "small" corrupted video (about 400mb) but unfortunately the smallest good video that i have is about 2.8gb, which i will include.
Output: