untrunc icon indicating copy to clipboard operation
untrunc copied to clipboard

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

Open evanmw opened this issue 5 years ago • 4 comments

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.

evanmw avatar Sep 22 '20 16:09 evanmw

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

anthwlock avatar Sep 23 '20 18:09 anthwlock

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.

evanmw avatar Sep 23 '20 20:09 evanmw

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 [email protected]:

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.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 avatar Sep 24 '20 08:09 anthwlock

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?

anthwlock avatar Oct 13 '20 13:10 anthwlock