ponchio / untrunc

Restore a damaged (truncated) mp4, m4v, mov, 3gp video. Provided you have a similar not broken video.
GNU General Public License v2.0
1.59k stars 224 forks source link

Disabling audio recovery? #140

Open jleclanche opened 5 years ago

jleclanche commented 5 years ago

I'm hitting what I think is #25:

                                                        untrunc ok3.mp4 bad.mp4            
Reading: ok3.mp4
Composition time offset atom found. Out of order samples possible.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ok3.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.6.100
  Duration: 00:47:40.23, start: 0.000000, bitrate: 1423 kb/s
    Stream #0:0(und): Video: h264 (High) [avc1 / 0x31637661]
      yuv420p, 1024x576, 1382 kb/s
      30 fps, 30 tbn (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 [mp4a / 0x6134706D]
      48000 Hz, 2 channels, s16p, 31 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Track codec: mp4a
Failure because of NULL header
Track codec: avc1
avc1: Match with 0 header

Length: 657
Ref idc: 0
Nal type: 6
Partial length: 657

Length: 31889
Ref idc: 3
Nal type: 5
First mb: 0
pic paramter set id: 0
Frame num: 0
field: 0
Idr pic: 15
Poc lsb: 0
Partial length: 32546

Length: 14266
Ref idc: 2
Nal type: 1
First mb: 0
pic paramter set id: 0
Frame num: 1
field: 0
Poc lsb: 8
Different frame number
Track codec: mp4a
Failure because of NULL header
Track codec: avc1
avc1: Match with 0 header

Length: 14266
Ref idc: 2
Nal type: 1
First mb: 0
pic paramter set id: 0
Frame num: 1
field: 0
Poc lsb: 8
Partial length: 14266

First byte expected 0
Track codec: mp4a
Success for no particular reason....
Duration: 1152
Track codec: avc1
avc1: failed for not particular reason
Found 2 packets
Track duration: 0 movie timescale: 1000 track timescale: 48000
Track duration: 2 movie timescale: 1000 track timescale: 30

untrunc generates the first two frames but then fails to generate the rest. Error appears to be in the audio portion... is it possible to disable it somehow (either in the code or in a flag), to see if it'd fare better?

ponchio commented 5 years ago

Hi, to rebuild the index, untrunc needs to guess start and lenght of every packet. Most probably in your case it failed to identify the type of packet correctly, the heuristic used to guess the packet could definitely be improved.

Alas no, disabling the audio wouldn't be of any help.

If you wish, you can send me the broken video and the small working sample, and I will try to understand what is the problem and if it can be fixed (and fix it). I might learn something :)

My email: ponchio@gmail,com

On Mon, Sep 10, 2018 at 12:58 AM, Jerome Leclanche <notifications@github.com

wrote:

I'm hitting what I think is #25 https://github.com/ponchio/untrunc/issues/25:

                                                    untrunc ok3.mp4 bad.mp4

Reading: ok3.mp4 Composition time offset atom found. Out of order samples possible. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'ok3.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf54.6.100 Duration: 00:47:40.23, start: 0.000000, bitrate: 1423 kb/s Stream #0:0(und): Video: h264 (High) [avc1 / 0x31637661] yuv420p, 1024x576, 1382 kb/s 30 fps, 30 tbn (default) Metadata: handler_name : VideoHandler Stream #0:1(und): Audio: mp3 [mp4a / 0x6134706D] 48000 Hz, 2 channels, s16p, 31 kb/s (default) Metadata: handler_name : SoundHandler Track codec: mp4a Failure because of NULL header Track codec: avc1 avc1: Match with 0 header

Length: 657 Ref idc: 0 Nal type: 6 Partial length: 657

Length: 31889 Ref idc: 3 Nal type: 5 First mb: 0 pic paramter set id: 0 Frame num: 0 field: 0 Idr pic: 15 Poc lsb: 0 Partial length: 32546

Length: 14266 Ref idc: 2 Nal type: 1 First mb: 0 pic paramter set id: 0 Frame num: 1 field: 0 Poc lsb: 8 Different frame number Track codec: mp4a Failure because of NULL header Track codec: avc1 avc1: Match with 0 header

Length: 14266 Ref idc: 2 Nal type: 1 First mb: 0 pic paramter set id: 0 Frame num: 1 field: 0 Poc lsb: 8 Partial length: 14266

First byte expected 0 Track codec: mp4a Success for no particular reason.... Duration: 1152 Track codec: avc1 avc1: failed for not particular reason Found 2 packets Track duration: 0 movie timescale: 1000 track timescale: 48000 Track duration: 2 movie timescale: 1000 track timescale: 30

untrunc generates the first two frames but then fails to generate the rest. Error appears to be in the audio portion... is it possible to disable it somehow (either in the code or in a flag), to see if it'd fare better?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ponchio/untrunc/issues/140, or mute the thread https://github.com/notifications/unsubscribe-auth/ACg66yU_VeRHLm78xKZ0lCYgPkYy3Z0yks5uZZ0BgaJpZM4Wgfxk .

jleclanche commented 5 years ago

I'll ask if I can send the file but I need permission first. I also tried @anthwlock's fork which seems to detect things better, but then fails on another issue: https://github.com/anthwlock/untrunc/issues/8

jleclanche commented 5 years ago

For this particular bug I messed about in the codebase quite a lot but consistently only got two frames generated.

jleclanche commented 5 years ago

Here's the full log of the fork which seems to detect more packets:

Info: reading files/ok3.mp4
Info: parsing healthy moov atom ... 

start_ = 0
requests: 4 at offset : 0
length_ = 32
requests: 4 at offset : 4
name_ = ftyp
requests: 24 at offset : 8

start_ = 32
requests: 4 at offset : 32
length_ = 8
requests: 4 at offset : 36
name_ = free
requests: 0 at offset : 40

start_ = 40
requests: 4 at offset : 40
length_ = 505803065
requests: 4 at offset : 44
name_ = mdat
requests: 505803057 at offset : 48
reallocating the file buffer

start_ = 505803105
requests: 4 at offset : 0
length_ = 3126351
requests: 4 at offset : 4
name_ = moov

start_ = 505803113
requests: 4 at offset : 8
length_ = 108
requests: 4 at offset : 12
name_ = mvhd
requests: 100 at offset : 16

start_ = 505803221
requests: 4 at offset : 116
length_ = 1369773
requests: 4 at offset : 120
name_ = trak

start_ = 505803229
requests: 4 at offset : 124
length_ = 92
requests: 4 at offset : 128
name_ = tkhd
requests: 84 at offset : 132

start_ = 505803321
requests: 4 at offset : 216
length_ = 36
requests: 4 at offset : 220
name_ = edts

start_ = 505803329
requests: 4 at offset : 224
length_ = 28
requests: 4 at offset : 228
name_ = elst
requests: 20 at offset : 232

start_ = 505803357
requests: 4 at offset : 252
length_ = 1369637
requests: 4 at offset : 256
name_ = mdia

start_ = 505803365
requests: 4 at offset : 260
length_ = 32
requests: 4 at offset : 264
name_ = mdhd
requests: 24 at offset : 268

start_ = 505803397
requests: 4 at offset : 292
length_ = 45
requests: 4 at offset : 296
name_ = hdlr
requests: 37 at offset : 300

start_ = 505803442
requests: 4 at offset : 337
length_ = 1369552
requests: 4 at offset : 341
name_ = minf

start_ = 505803450
requests: 4 at offset : 345
length_ = 20
requests: 4 at offset : 349
name_ = vmhd
requests: 12 at offset : 353

start_ = 505803470
requests: 4 at offset : 365
length_ = 36
requests: 4 at offset : 369
name_ = dinf

start_ = 505803478
requests: 4 at offset : 373
length_ = 28
requests: 4 at offset : 377
name_ = dref
requests: 20 at offset : 381

start_ = 505803506
requests: 4 at offset : 401
length_ = 1369488
requests: 4 at offset : 405
name_ = stbl

start_ = 505803514
requests: 4 at offset : 409
length_ = 152
requests: 4 at offset : 413
name_ = stsd
requests: 144 at offset : 417

start_ = 505803666
requests: 4 at offset : 561
length_ = 24
requests: 4 at offset : 565
name_ = stts
requests: 16 at offset : 569

start_ = 505803690
requests: 4 at offset : 585
length_ = 1392
requests: 4 at offset : 589
name_ = stss
requests: 1384 at offset : 593

start_ = 505805082
requests: 4 at offset : 1977
length_ = 681384
requests: 4 at offset : 1981
name_ = ctts
requests: 681376 at offset : 1985

start_ = 506486466
requests: 4 at offset : 683361
length_ = 40
requests: 4 at offset : 683365
name_ = stsc
requests: 32 at offset : 683369

start_ = 506486506
requests: 4 at offset : 683401
length_ = 343248
requests: 4 at offset : 683405
name_ = stsz
requests: 343240 at offset : 683409

start_ = 506829754
requests: 4 at offset : 1026649
length_ = 343240
requests: 4 at offset : 1026653
name_ = stco
requests: 343232 at offset : 1026657

start_ = 507172994
requests: 4 at offset : 1369889
length_ = 1756365
requests: 4 at offset : 1369893
name_ = trak

start_ = 507173002
requests: 4 at offset : 1369897
length_ = 92
requests: 4 at offset : 1369901
name_ = tkhd
requests: 84 at offset : 1369905

start_ = 507173094
requests: 4 at offset : 1369989
length_ = 36
requests: 4 at offset : 1369993
name_ = edts

start_ = 507173102
requests: 4 at offset : 1369997
length_ = 28
requests: 4 at offset : 1370001
name_ = elst
requests: 20 at offset : 1370005

start_ = 507173130
requests: 4 at offset : 1370025
length_ = 1756229
requests: 4 at offset : 1370029
name_ = mdia

start_ = 507173138
requests: 4 at offset : 1370033
length_ = 32
requests: 4 at offset : 1370037
name_ = mdhd
requests: 24 at offset : 1370041

start_ = 507173170
requests: 4 at offset : 1370065
length_ = 45
requests: 4 at offset : 1370069
name_ = hdlr
requests: 37 at offset : 1370073

start_ = 507173215
requests: 4 at offset : 1370110
length_ = 1756144
requests: 4 at offset : 1370114
name_ = minf

start_ = 507173223
requests: 4 at offset : 1370118
length_ = 16
requests: 4 at offset : 1370122
name_ = smhd
requests: 8 at offset : 1370126

start_ = 507173239
requests: 4 at offset : 1370134
length_ = 36
requests: 4 at offset : 1370138
name_ = dinf

start_ = 507173247
requests: 4 at offset : 1370142
length_ = 28
requests: 4 at offset : 1370146
name_ = dref
requests: 20 at offset : 1370150

start_ = 507173275
requests: 4 at offset : 1370170
length_ = 1756084
requests: 4 at offset : 1370174
name_ = stbl

start_ = 507173283
requests: 4 at offset : 1370178
length_ = 96
requests: 4 at offset : 1370182
name_ = stsd
requests: 88 at offset : 1370186

start_ = 507173379
requests: 4 at offset : 1370274
length_ = 611944
requests: 4 at offset : 1370278
name_ = stts
requests: 611936 at offset : 1370282

start_ = 507785323
requests: 4 at offset : 1982218
length_ = 800776
requests: 4 at offset : 1982222
name_ = stsc
requests: 800768 at offset : 1982226

start_ = 508586099
requests: 4 at offset : 2782994
length_ = 20
requests: 4 at offset : 2782998
name_ = stsz
requests: 12 at offset : 2783002

start_ = 508586119
requests: 4 at offset : 2783014
length_ = 343240
requests: 4 at offset : 2783018
name_ = stco
requests: 343232 at offset : 2783022

start_ = 508929359
requests: 4 at offset : 3126254
length_ = 97
requests: 4 at offset : 3126258
name_ = udta
requests: 89 at offset : 3126262
Composition time offset atom found. Out of order samples possible.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'files/ok3.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.6.100
  Duration: 00:47:40.23, start: 0.000000, bitrate: 1423 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1024x576, 1382 kb/s, 30 fps, 30 tbr, 30 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 31 kb/s (default)
    Metadata:
      handler_name    : SoundHandler