anthwlock / untrunc

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

Assertion failed! Expression: constant_duration_ == 160 #72

Closed megapro17 closed 3 years ago

megapro17 commented 3 years ago
PS D:\Users\megapro17\Desktop\Photos> untrunc video0155ok.mp4 video0145.mp4
Info: version 'd6f0790' using ffmpeg '3.3.4'
Info: reading video0155ok.mp4
Info: parsing healthy moov atom ...

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

Assertion failed!

Program: D:\Users\megapro17\Desktop\Soft\Path\untrunc_x64\untrunc.exe
File: src/track.cpp, Line 211

Expression: constant_duration_ == 160

PS D:\Users\megapro17\Desktop\Photos> untrunc -s video0155ok.mp4 video0145.mp4
Info: version 'd6f0790' using ffmpeg '3.3.4'
Info: reading video0155ok.mp4
Info: parsing healthy moov atom ...

Info: reading mdat from truncated file ...
Assertion failed!

Program: D:\Users\megapro17\Desktop\Soft\Path\untrunc_x64\untrunc.exe
File: src/track.cpp, Line 211

Expression: constant_duration_ == 160

The same error if two files are not damaged

megapro17 commented 3 years ago

I guess it is a problem with amr? Because after commenting that assert I can watch video, but audio has wrong duration

PS D:\Users\megapro17\Desktop\Photos> untrunc -vv video0155ok.mp4 video0151.mp4
Info: version 'd6f0790' using ffmpeg '3.3.4'
Info: reading video0155ok.mp4
Info: parsing healthy moov atom ...
requests: 4 at offset : 0
requests: 4 at offset : 4
start_ = 0
length_ = 24
name_ = ftyp

requests: 16 at offset : 8

requests: 4 at offset : 24
requests: 4 at offset : 28
start_ = 24
length_ = 610549
name_ = mdat

requests: 4 at offset : 610573
requests: 4 at offset : 610577
start_ = 610573
length_ = 4374
name_ = moov

requests: 4 at offset : 610581
requests: 4 at offset : 610585
start_ = 610581
length_ = 108
name_ = mvhd

requests: 100 at offset : 610589

requests: 4 at offset : 610689
requests: 4 at offset : 610693
start_ = 610689
length_ = 33
name_ = iods

requests: 25 at offset : 610697

requests: 4 at offset : 610722
requests: 4 at offset : 610726
start_ = 610722
length_ = 1054
name_ = trak

requests: 4 at offset : 610730
requests: 4 at offset : 610734
start_ = 610730
length_ = 92
name_ = tkhd

requests: 84 at offset : 610738

requests: 4 at offset : 610822
requests: 4 at offset : 610826
start_ = 610822
length_ = 48
name_ = edts

requests: 4 at offset : 610830
requests: 4 at offset : 610834
start_ = 610830
length_ = 40
name_ = elst

requests: 32 at offset : 610838

requests: 4 at offset : 610870
requests: 4 at offset : 610874
start_ = 610870
length_ = 906
name_ = mdia

requests: 4 at offset : 610878
requests: 4 at offset : 610882
start_ = 610878
length_ = 32
name_ = mdhd

requests: 24 at offset : 610886

requests: 4 at offset : 610910
requests: 4 at offset : 610914
start_ = 610910
length_ = 37
name_ = hdlr

requests: 29 at offset : 610918

requests: 4 at offset : 610947
requests: 4 at offset : 610951
start_ = 610947
length_ = 829
name_ = minf

requests: 4 at offset : 610955
requests: 4 at offset : 610959
start_ = 610955
length_ = 36
name_ = dinf

requests: 4 at offset : 610963
requests: 4 at offset : 610967
start_ = 610963
length_ = 28
name_ = dref

requests: 20 at offset : 610971

requests: 4 at offset : 610991
requests: 4 at offset : 610995
start_ = 610991
length_ = 16
name_ = smhd

requests: 8 at offset : 610999

requests: 4 at offset : 611007
requests: 4 at offset : 611011
start_ = 611007
length_ = 769
name_ = stbl

requests: 4 at offset : 611015
requests: 4 at offset : 611019
start_ = 611015
length_ = 24
name_ = stts

requests: 16 at offset : 611023

requests: 4 at offset : 611039
requests: 4 at offset : 611043
start_ = 611039
length_ = 20
name_ = stsz

requests: 12 at offset : 611047

requests: 4 at offset : 611059
requests: 4 at offset : 611063
start_ = 611059
length_ = 28
name_ = stsc

requests: 20 at offset : 611067

requests: 4 at offset : 611087
requests: 4 at offset : 611091
start_ = 611087
length_ = 604
name_ = stco

requests: 596 at offset : 611095

requests: 4 at offset : 611691
requests: 4 at offset : 611695
start_ = 611691
length_ = 16
name_ = stss

requests: 8 at offset : 611699

requests: 4 at offset : 611707
requests: 4 at offset : 611711
start_ = 611707
length_ = 69
name_ = stsd

requests: 61 at offset : 611715

requests: 4 at offset : 611776
requests: 4 at offset : 611780
start_ = 611776
length_ = 3171
name_ = trak

requests: 4 at offset : 611784
requests: 4 at offset : 611788
start_ = 611784
length_ = 92
name_ = tkhd

requests: 84 at offset : 611792

requests: 4 at offset : 611876
requests: 4 at offset : 611880
start_ = 611876
length_ = 3071
name_ = mdia

requests: 4 at offset : 611884
requests: 4 at offset : 611888
start_ = 611884
length_ = 32
name_ = mdhd

requests: 24 at offset : 611892

requests: 4 at offset : 611916
requests: 4 at offset : 611920
start_ = 611916
length_ = 37
name_ = hdlr

requests: 29 at offset : 611924

requests: 4 at offset : 611953
requests: 4 at offset : 611957
start_ = 611953
length_ = 2994
name_ = minf

requests: 4 at offset : 611961
requests: 4 at offset : 611965
start_ = 611961
length_ = 36
name_ = dinf

requests: 4 at offset : 611969
requests: 4 at offset : 611973
start_ = 611969
length_ = 28
name_ = dref

requests: 20 at offset : 611977

requests: 4 at offset : 611997
requests: 4 at offset : 612001
start_ = 611997
length_ = 20
name_ = vmhd

requests: 12 at offset : 612005

requests: 4 at offset : 612017
requests: 4 at offset : 612021
start_ = 612017
length_ = 2930
name_ = stbl

requests: 4 at offset : 612025
requests: 4 at offset : 612029
start_ = 612025
length_ = 1160
name_ = stts

requests: 1152 at offset : 612033

requests: 4 at offset : 613185
requests: 4 at offset : 613189
start_ = 613185
length_ = 732
name_ = stsz

requests: 724 at offset : 613193

requests: 4 at offset : 613917
requests: 4 at offset : 613921
start_ = 613917
length_ = 28
name_ = stsc

requests: 20 at offset : 613925

requests: 4 at offset : 613945
requests: 4 at offset : 613949
start_ = 613945
length_ = 728
name_ = stco

requests: 720 at offset : 613953

requests: 4 at offset : 614673
requests: 4 at offset : 614677
start_ = 614673
length_ = 64
name_ = stss

requests: 56 at offset : 614681

requests: 4 at offset : 614737
requests: 4 at offset : 614741
start_ = 614737
length_ = 210
name_ = stsd

requests: 202 at offset : 614745

ftyp_ = 'isom'
[NULL @ 0000000002580800] Opening 'video0155ok.mp4' for reading
[file @ 0000000002581f20] Setting default whitelist 'file,crypto'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] Format mov,mp4,m4a,3gp,3g2,mj2 probed with size=2048 and score=100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] ISO: File Type Major Brand: isom
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] Processing st: 0, edit list 0 - media time: -1, duration: 25
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] Processing st: 0, edit list 1 - media time: 0, duration: 11913
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] Unknown dref type 0x206c7275 size 12
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] rfps: 15.000000 0.008611
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] rfps: 15.083333 0.004917
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] rfps: 15.083333 0.004917
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] rfps: 14.985015 0.014546
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] Before avformat_find_stream_info() pos: 614947 bytes read:37142 seeks:1 nb_streams:2
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] All info found
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000000002580800] After avformat_find_stream_info() pos: 7108 bytes read:69910 seeks:2 frames:3
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video0155ok.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: skm23gp5
    creation_time   : 2035-12-31T23:37:30.000000Z
  Duration: 00:00:11.91, start: 0.000000, bitrate: 412 kb/s
    Stream #0:0(und), 1, 1/1000: Audio: amr_nb (samr / 0x726D6173), 8000 Hz, mono, flt, 12 kb/s (default)
    Metadata:
      creation_time   : 2035-12-31T23:37:30.000000Z
      handler_name    : soun
    Stream #0:1(und), 2, 1/1000: Video: mpeg4 (Simple Profile), 1 reference frame (mp4v / 0x7634706D), yuv420p(left), 320x240 [SAR 1:1 DAR 4:3], 0/1, 397 kb/s, 14.94 fps, 15.08 tbr, 1k tbn, 15 tbc (default)
    Metadata:
      creation_time   : 2035-12-31T23:37:30.000000Z
      handler_name    : vide

calling findMdat on truncated file..
requests: 4 at offset : 0
requests: 4 at offset : 4
start_ = 0
length_ = 24
name_ = ftyp

requests: 4 at offset : 24
requests: 4 at offset : 28
start_ = 24
length_ = 24
name_ = mdat

Info: reading mdat from truncated file ...

(reading element from mdat)
Offset: 0 / 32 : 000001b6 10c2a309
Track codec: samr
Track codec: mp4v
part-length: 2241
1th sample in 1th mp4v-chunk

(reading element from mdat)
Offset: 2241 / 2273 : 000001b6 51c0c6b6
Track codec: samr
Track codec: mp4v
part-length: 1254
2th sample in 1th mp4v-chunk

(reading element from mdat)
Offset: 3495 / 3527 : 3c92626d 087804f2
Track codec: samr
part-length: 32
1th sample in 1th samr-chunk

(reading element from mdat)
Offset: 3527 / 3559 : 3c706664 0067f47b
Track codec: samr
part-length: 32
2th sample in 1th samr-chunk

(reading element from mdat)
Offset: 3559 / 3591 : 3c6a6268 0867cbd3
Track codec: samr
part-length: 32
3th sample in 1th samr-chunk

(reading element from mdat)
Offset: 3591 / 3623 : 3c946228 0867855a
Track codec: samr
part-length: 32
4th sample in 1th samr-chunk

(reading element from mdat)
Offset: 3623 / 3655 : 000001b6 52e0c7da
Track codec: samr
Track codec: mp4v
part-length: 5735
1th sample in 2th mp4v-chunk

(reading element from mdat)
Offset: 9358 / 9390 : 3c7c6980 08664af3
Track codec: samr
part-length: 32
1th sample in 2th samr-chunk

(reading element from mdat)
Offset: 9390 / 9422 : 3c766220 0866630e
Track codec: samr
part-length: 32
2th sample in 2th samr-chunk

(reading element from mdat)
Offset: 9422 / 9454 : 3c7262d8 10661ba6
Track codec: samr
part-length: 32
3th sample in 2th samr-chunk

(reading element from mdat)
Offset: 9454 / 9486 : 3c6c6224 006631f0
Track codec: samr
part-length: 32
4th sample in 2th samr-chunk

(reading element from mdat)
Offset: 9486 / 9518 : 000001b6 53c0a430
Track codec: samr
Track codec: mp4v
part-length: 2309
1th sample in 3th mp4v-chunk

(reading element from mdat)
Offset: 11795 / 11827 : 000001b6 54e0a5be
Track codec: samr
Track codec: mp4v
part-length: 5244
2th sample in 3th mp4v-chunk

(reading element from mdat)
Offset: 17039 / 17071 : 3c9a6229 20663df1
Track codec: samr
part-length: 32
1th sample in 3th samr-chunk

(reading element from mdat)
Offset: 17071 / 17103 : 3c7c622d 086635e8
Track codec: samr
part-length: 32
2th sample in 3th samr-chunk

(reading element from mdat)
Offset: 17103 / 17135 : 3c9a621b 10660fe0
Track codec: samr
part-length: 32
3th sample in 3th samr-chunk

(reading element from mdat)
Offset: 17135 / 17167 : 3cac6230 10661de0
Track codec: samr
part-length: 32
4th sample in 3th samr-chunk

(reading element from mdat)
Offset: 17167 / 17199 : 000001b6 55c08590
Track codec: samr
Track codec: mp4v
part-length: 1923
1th sample in 4th mp4v-chunk

(reading element from mdat)
Offset: 19090 / 19122 : 3c8863a1 08661bf8
Track codec: samr
part-length: 32
1th sample in 4th samr-chunk

(reading element from mdat)
Offset: 19122 / 19154 : 3cac6257 10660de7
Track codec: samr
part-length: 32
2th sample in 4th samr-chunk

(reading element from mdat)
Offset: 19154 / 19186 : 3c706380 10660587
Track codec: samr
part-length: 32
3th sample in 4th samr-chunk

(reading element from mdat)
Offset: 19186 / 19218 : 3caa68dc 1064a379
Track codec: samr
part-length: 32
4th sample in 4th samr-chunk

(reading element from mdat)
Offset: 19218 / 19250 : 000001b6 56e0850b
Track codec: samr
Track codec: mp4v
part-length: 2560
1th sample in 5th mp4v-chunk

(reading element from mdat)
Offset: 21778 / 21810 : 3ca2622d 5061efb4
Track codec: samr
part-length: 32
1th sample in 5th samr-chunk

(reading element from mdat)
Offset: 21810 / 21842 : 3c9b421c 086486bf
Track codec: samr
part-length: 32
2th sample in 5th samr-chunk

(reading element from mdat)
Offset: 21842 / 21874 : 3c8868d6 1861970e
Track codec: samr
part-length: 32
3th sample in 5th samr-chunk

(reading element from mdat)
Offset: 21874 / 21906 : 3cbd421d 58613d6a
Track codec: samr
part-length: 32
4th sample in 5th samr-chunk

(reading element from mdat)
Offset: 21906 / 21938 : 000001b6 57c06526
Track codec: samr
Track codec: mp4v
part-length: 3629
1th sample in 6th mp4v-chunk

(reading element from mdat)
Offset: 25535 / 25567 : 3c8868d6 08606cb4
Track codec: samr
part-length: 32
1th sample in 6th samr-chunk

(reading element from mdat)
Offset: 25567 / 25599 : 3cbd4388 58605b2c
Track codec: samr
part-length: 32
2th sample in 6th samr-chunk

(reading element from mdat)
Offset: 25599 / 25631 : 3c56ebf1 78601fb5
Track codec: samr
part-length: 32
3th sample in 6th samr-chunk

(reading element from mdat)
Offset: 25631 / 25663 : 3ca34224 10601d6d
Track codec: samr
part-length: 32
4th sample in 6th samr-chunk

(reading element from mdat)
Offset: 25663 / 25695 : 000001b6 58e06441
Track codec: samr
Track codec: mp4v
part-length: 3379
1th sample in 7th mp4v-chunk

(reading element from mdat)
Offset: 29042 / 29074 : 3c6cebf1 08601dec
Track codec: samr
part-length: 32
1th sample in 7th samr-chunk

(reading element from mdat)
Offset: 29074 / 29106 : 3cb14380 50600c78
Track codec: samr
part-length: 32
2th sample in 7th samr-chunk

(reading element from mdat)
Offset: 29106 / 29138 : 3c2c68d6 5060209e
Track codec: samr
part-length: 32
3th sample in 7th samr-chunk

(reading element from mdat)
Offset: 29138 / 29170 : 3c88ec6c 70600c05
Track codec: samr
part-length: 32
4th sample in 7th samr-chunk

(reading element from mdat)
Offset: 29170 / 29202 : 000001b6 59c06522
Track codec: samr
Track codec: mp4v
part-length: 3937
1th sample in 8th mp4v-chunk

(reading element from mdat)
Offset: 33107 / 33139 : 000001b6 5ae04428
Track codec: samr
Track codec: mp4v
part-length: 2758
2th sample in 8th mp4v-chunk

(reading element from mdat)
Offset: 35865 / 35897 : 3cf8626f 510eff3d
Track codec: samr
part-length: 32
1th sample in 8th samr-chunk

(reading element from mdat)
Offset: 35897 / 35929 : 3c7af26c 704aa81c
Track codec: samr
part-length: 32
2th sample in 8th samr-chunk

(reading element from mdat)
Offset: 35929 / 35961 : 3c6e698d 1895f427
Track codec: samr
part-length: 32
3th sample in 8th samr-chunk

(reading element from mdat)
Offset: 35961 / 35993 : 3ca3366c 704aa697
Track codec: samr
part-length: 32
4th sample in 8th samr-chunk

(reading element from mdat)
Offset: 35993 / 36025 : 000001b6 5bc065c1
Track codec: samr
Track codec: mp4v
part-length: 5176
1th sample in 9th mp4v-chunk

(reading element from mdat)
Offset: 41169 / 41201 : 3c68698d 701fec7a
Track codec: samr
part-length: 32
1th sample in 9th samr-chunk

(reading element from mdat)
Offset: 41201 / 41233 : 3c7b4269 101fe9ad
Track codec: samr
part-length: 32
2th sample in 9th samr-chunk

(reading element from mdat)
Offset: 41233 / 41265 : 3c68eb8d 7035504b
Track codec: samr
part-length: 32
3th sample in 9th samr-chunk

(reading element from mdat)
Offset: 41265 / 41297 : 3c9b4223 186023da
Track codec: samr
part-length: 32
4th sample in 9th samr-chunk

(reading element from mdat)
Offset: 41297 / 41329 : 000001b6 5ce04429
Track codec: samr
Track codec: mp4v
part-length: 3557
1th sample in 10th mp4v-chunk

(reading element from mdat)
Offset: 44854 / 44886 : 7f3cbc69 8248606e
Track codec: samr
Track codec: mp4v
Error: unable to find correct codec -> premature end (~0.7605%)
       try '-s' to skip unknown sequences

mdat->file_end: 44886
Assertion failed!

Program: D:\Users\megapro17\Desktop\Soft\Path\untrunc_x64\untrunc.exe
File: src/track.cpp, Line 211

Expression: constant_duration_ == 160
anthwlock commented 3 years ago

Have you tried using -s? It would be interesting to know, what duration your samr samples have, in order to improve the assertion. Can you send them (your files) to me?

megapro17 commented 3 years ago

Have you tried using -s?

yes, as i said with this parameter I can recovery video if assert is commented

Can you send them (your files) to me?

Of course videos.zip

megapro17 commented 3 years ago

Did anything work out?

anthwlock commented 3 years ago

The duration assertion was not the only wrong thing. As this comment says, samr samples have a size multiple of 32. In this case 128. But the "splitting" the comment refers to doen't work, often 3/4 of the sample is lost/not played correctly. However the correct size is read from the reference file, and stored in constant_size_. So one can just use that instead, see 8024f0cfbbc94c70a30004726fbfa6b23baa8b63

megapro17 commented 3 years ago

it works now, update windows build pls

anthwlock commented 3 years ago

windows builds are updated automagically :)

megapro17 commented 3 years ago

it's not working since march

anthwlock commented 3 years ago

It does work. What likely confuses you is that it is the (exact) same release, which gets updated on each commit. Look at Head and Date in the release message: a