anthwlock / untrunc

Restore a truncated mp4/mov. Improved version of ponchio/untrunc
GNU General Public License v2.0
1.9k stars 182 forks source link

"unable to find correct codec" and restore fails #29

Closed suuuehgi closed 5 years ago

suuuehgi commented 5 years ago

The actual file is about 45 min long.

$ ./untrunc reference.mp4 corrupt.mp4
Info: version '43037a2' using ffmpeg '4.1.3-1'
Info: reading /var/spool/recordings/hs6-20190702T111031.mp4
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: searching start of mdat ... 
Info: reading mdat from truncated file ...
[aac @ 0x55ddc3c09ac0] Multiple frames in a packet.
[aac @ 0x55ddc3c09ac0] Prediction is not allowed in AAC-LC.
Error: unable to find correct codec -> premature end
       try '-s' to skip unknown sequences

Info: Found 281 packets ( mp4a: 179 avc1: 102 avc1-keyframes: 2 )
[...]

ffmpeg '4.1.3-1'

$ ./untrunc -s reference.mp4 corrupt.mp4
WARNING: Because of internal decoder changes, using ffmpeg '4.1.3-1' with '-s' can be slow!
         You are advised to compile untrunc against ffmpeg 3.3!
         See the README.md on how to do that. Press [ENTER] to continue ... 
Info: version '43037a2' using ffmpeg '4.1.3-1'
Info: reading /var/spool/recordings/hs6-20190702T111031.mp4
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: searching start of mdat ... 
Info: reading mdat from truncated file ...
[aac @ 0x55e93a4a1080] Multiple frames in a packet.
[aac @ 0x55e93a4a1080] Prediction is not allowed in AAC-LC.
Info: Found 281 packets ( mp4a: 179 avc1: 102 avc1-keyframes: 2 )
Info: Duration of mp4a: 3s 818ms  (3818 ms)
Info: Duration of avc1: 4s 25ms  (4025 ms)
Warning: Unknown sequences: 1
Warning: Bytes not matched: 35MiB (0%)

ffmpeg '3.3.9'

$ ./untrunc -s reference.mp4 corrupt.mp4
Info: version '43037a2' using ffmpeg '3.3.9'
Info: reading /var/spool/recordings/hs6-20190702T111031.mp4
Info: parsing healthy moov atom ... 
Info: avcC got decoded
Info: searching start of mdat ... 
Info: reading mdat from truncated file ...
[aac @ 0x564d340ab1c0] Multiple frames in a packet.
[aac @ 0x564d340ab1c0] Number of bands (46) exceeds limit (43).
Info: unknown sequence -> muting ffmpeg and warnings ..
Info: Found 281 packets ( mp4a: 179 avc1: 102 avc1-keyframes: 2 )
Info: Duration of mp4a: 3s 818ms  (3818 ms)
Info: Duration of avc1: 4s 25ms  (4025 ms)
Warning: Unknown sequences: 1
Warning: Bytes not matched: 35MiB (0%)
anthwlock commented 5 years ago

I would like to help you, but I need the files you are having problems with. A small sample should be enough, you can use head -c 10M corrupt.mp4 > corrupt_head.mp4. Please send me the link (email or here) to the files and I will take a look.

suuuehgi commented 5 years ago

Thanks a lot! You have an email.

suuuehgi commented 5 years ago

Awesome! untrunc -s succeeds now! Thanks a ton!

untrunc alone still fails. Why is this the case?

anthwlock commented 5 years ago

In some cases, the corrupt file contains actual data up to a point x, and then garbage. The default assertion is that x is where the first match fails, so it stops there.

But in some cases, either untrunc fails to match an existing sample, or the garbage section is "temporary". In these cases you should use -s.

There is no special reason why the default assertion is that way.

Btw, you can use untrunc -h for a short description of the available options