anthwlock / untrunc

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

Unable to find correct codec #137

Open heph2 opened 1 year ago

heph2 commented 1 year ago

Hi! I'm trying to repair an mp4 video (saved as an RSV file from the camera, which is a sony alpha 7s III), but i got those issues:

untrunc -v 20230321_A.B.0323.MP4 badvideo.mp4                                                                           Fri Mar 24 22:01:11 2023
Info: version '' using ffmpeg '4.4.2'
Info: reading 20230321_A.B.0323.MP4
Info: parsing healthy moov atom ... 
Composition time offset atom found. Out of order samples possible.
ftyp_ = 'XAVC'
detected 'XAVC', deactivating 'g_strict_nal_frame_check'
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x139811400] st: 0 edit list: 1 Missing key frame while searching for timestamp: 2000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x139811400] st: 0 edit list 1 Cannot find an index entry before timestamp: 2000.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '20230321_A.B.0323.MP4':
  Metadata:
    major_brand     : XAVC
    minor_version   : 17440767
    compatible_brands: XAVCmp42iso2nras
    creation_time   : 2023-03-21T17:01:10.000000Z
  Duration: 00:01:25.44, start: 0.000000, bitrate: 103697 kb/s
  Stream #0:0(und): Video: hevc (Rext) (hvc1 / 0x31637668), yuv422p10le(tv, bt709), 3840x2160 [SAR 1:1 DAR 16:9], 97048 kb/s, 50 fps, 50 tbr, 50k tbn, 50 tbc (default)
    Metadata:
      creation_time   : 2023-03-21T17:01:10.000000Z
      handler_name    : Video Media Handler
      vendor_id       : [0][0][0][0]
      encoder         : HEVC Coding
  Stream #0:1(und): Audio: pcm_s16be (twos / 0x736F7774), 48000 Hz, 2 channels, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2023-03-21T17:01:10.000000Z
      handler_name    : Sound Media Handler
      vendor_id       : [0][0][0][0]
  Stream #0:2(und): Data: none (rtmd / 0x646D7472), 4505 kb/s (default)
    Metadata:
      creation_time   : 2023-03-21T17:01:10.000000Z
      handler_name    : Timed Metadata Media Handler
      timecode        : 04:15:03:18
assuming constant duration of 1000 for 'hvc1' (x4272)
assuming constant duration of 1 for 'twos' (x4101120)
assuming constant duration of 1000 for 'rtmd' (x4272)
Info: special track found (meta, 'Timed Metadata Media Handler')

Info: unknown track 'twos' found -> fallback to dynamic stats
created dummy track 'free'
removed dummy track 'free'
first_failed: 0 of 100
order: (2, 48) (0, 48) (1, 46080) 
isTrackOrderEnough: 1  (sz=3)

dynamic stats:
first_off_: 131072
first_off_rel_: 0
hvc1
chunk_distance_gcd_: 1
likely n_samples/chunk (p=1): 48 
likely sample_sizes (p=0): 
n_mutual_patterns: 0

twos
chunk_distance_gcd_: 1
likely n_samples/chunk (p=1): 46080 
likely sample_sizes (p=1): 4 
n_mutual_patterns: 0

rtmd
chunk_distance_gcd_: 1
likely n_samples/chunk (p=1): 48 
likely sample_sizes (p=1): 11264 
n_mutual_patterns: 0

Info: using dynamic stats, use '-is' to see them
calling findMdat on truncated file..
Warning: no mp4-structure found in: 'badvideo.mp4'
Info: using orig_mdat_start_ (=131056)
Info: reading mdat from truncated file ...
Info: using 64-bit offsets for the broken file
won't skip zeros at: 0 / 131064

(reading element from mdat)
Offset: 0 / 131064 : 00000000 00000000
trying chunkPredict first.. 
called getChunkPrediction(0 / 131064) ... 
chunk derived from track_order_:'rtmd' (11264 x48)

(reading element from mdat)
Offset: 540672 / 671736 : 7b406865 0fa8fc40
trying chunkPredict first.. 
called getChunkPrediction(540672 / 671736) ... 
Track codec: hvc1
Track codec: twos
Track codec: rtmd
Error: unable to find correct codec -> premature end (~0.0009298%)
       try '-s' to skip unknown sequences

mdat->file_end: 671736
Info: Found 48 packets ( hvc1: 0 hvc1-keyframes: 0 twos: 0 rtmd: 48 )
first_failed: 0 of 4272
order: (1, 5000) (1, 2000) (1, 0) (1, 1000) 
reduced origt_ctts_: 4272 -> 4
Info: Duration of hvc1:  (0 ms)
Info: Duration of twos:  (0 ms)
Info: Duration of rtmd: 960ms  (960 ms)
Info: pruned empty 'hvc1' track
Info: pruned empty 'twos' track
Info: saving badvideo.mp4_fixed-dyn.MP4

Using the -s flag i got:

Info: saving result.3gp_fixed-s1-dyn.mp4
Assertion failed: (end - start == new_length), function write, file src/atom.cpp, line 483.
fish: Job 1, 'untrunc -s goodvideo.mp4 resu...' terminated by signal SIGABRT (Abort)
helinwang commented 7 months ago

What fixed the problem (not sure which one) for my case is:

My camera is a7iii