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

Error: unable to find correct codec -> premature end (~0%) #67

Open evanmw opened 3 years ago

evanmw commented 3 years ago

Hi, I'm trying to recover a video that was being encoded when a hard power-off of the computer occurred. If I use the -s option, I end up with a grey video.

Built yesterday from master with local libraries on Ubuntu 16.04.

Info: version '' using ffmpeg '3.3.9'
Info: reading good.mp4
Info: parsing healthy moov atom ... 
Warning: avcC was not decoded correctly

Info: reading mdat from truncated file ...
Error: unable to find correct codec -> premature end (~0%)
       try '-s' to skip unknown sequences

Warning: guessed frame durations of 'avc1' will probably be wrong!
Info: Found 0 packets ( avc1: 0 avc1-keyframes: 0 )
Info: Duration of avc1:  (0 ms)
Info: pruned empty 'avc1' track
Info: saving bad.mp4_fixed.mp4

2 warnings were hidden!

I'll definitely try this suggestion in the future. Thanks for any help you can offer.

anthwlock commented 3 years ago

Without files (healthy + broken) I can't offer you any help.

evanmw commented 3 years ago

I just emailed you a link to files. One note- I created the healthy clip with untrunc -sh healthy.mp4. When I run untrunc -i healthy.mp4_short-200.mp4, I get:

Info: version '' using ffmpeg '3.3.9'
Info: reading healthy.mp4_short-200.mp4
Info: parsing healthy moov atom ... 
Warning: avcC was not decoded correctly
untrunc: src/mp4.cpp:153: void Mp4::parseTracksOk(): Assertion `track.chunks_.back().off_ < mdats.back()->start_ + mdats.back()->length_' failed.
Aborted (core dumped)

Is this expected? untrunc -i healthy.mp4 with the full healthy video works.

anthwlock commented 3 years ago

Yes, it is. It means that there is less data than referenced by the moov atom. This can be ignored by passing -dcc.

  1. Sept. 2020, 22:25 von notifications@github.com:

I just emailed you a link to files. One note- I created the healthy clip with > untrunc -sh healthy.mp4> . When I run > untrunc -i healthy.mp4_short-200.mp4> , I get:

Info: version '' using ffmpeg '3.3.9'Info: reading healthy.mp4short-200.mp4Info: parsing healthy moov atom ... Warning: avcC was not decoded correctlyuntrunc: src/mp4.cpp:153: void Mp4::parseTracksOk(): Assertion `track.chunks.back().off < mdats.back()->start + mdats.back()->length_' failed.Aborted (core dumped)

Is this expected? > untrunc -i healthy.mp4> with the full healthy video works.

— You are receiving this because you commented. Reply to this email directly, > view it on GitHub https://github.com/anthwlock/untrunc/issues/67#issuecomment-697953361> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/AJQZFONNCZ2MU3J63PLTN7DSHJKTRANCNFSM4RV7ZY2Q> .

anthwlock commented 3 years ago

Your avc1 track seems to use the "annex b" byte-stream format. untrunc's code currently assumes the (more popular) "avcc" format. I wrote this "FIXIT" 2 years ago: https://github.com/anthwlock/untrunc/blob/ebeaa12680fb029739d9389ecde28b2417622103/src/avc1/nal.cpp#L25-L28

What's nice is that it looks like "annex b" can be used directly (e.g. without a container). So you can recover your files by skipping to the raw data, like this: dd if=bad.mp4 of=bad.h264 skip=48 iflag=skip_bytes,count_bytes

Do you have any idea how you ended up with this "annex b" in an mp4/mov file? What tool did you use to create these files? Did you somehow use ffmpeg's 264_mp4toannexb filter?