Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Add more prints to help debugging #1
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasRosenstein authored Dec 20, 2019
1 parent d176373 commit 42843e5
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions movrepair.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@
import sys





def guess_sequence_repitition_length(seq):
# Thanks to https://stackoverflow.com/a/11385797/791713
guess = 1
Expand Down Expand Up @@ -157,11 +154,11 @@ def get_new_duration(atom):
stsz_atom = stbl.find_atoms(b'stsz')[0]
stsz = movatoms.stsz.unpack(stsz_atom.data)
if len(stsz.table) > 1:
print('Extending {} sample size table'.format(data_format))
count = int(len(stsz.table) * scale_factor)
print('stsz count:', count)
deltas = calc_item_delta(stsz.table)
repn = guess_sequence_repitition_length(deltas)
print('Extending {} sample size table (table size: {}, guesssed repartition length: {})'
.format(data_format, repn))
offset = len(deltas) % repn
for i in range(count-len(stsz.table)):
delta = deltas[offset+(i%repn)]
Expand Down Expand Up @@ -223,7 +220,8 @@ def repair_file(reference, broken, output, do_fix_metadata=True):

# Update the duration and sample counts in the metadata.
if do_fix_metadata:
scale_factor = mdat.size / reference_atoms[b'mdat'].size
scale_factor = mdat.size / float(reference_atoms[b'mdat'].size)
print('Scale factor to fix metadata:', scale_factor)
fix_metadata(scale_factor, reference_atoms[b'moov'])

# Write the reference file's atoms and the mdat from the broken file.
Expand Down

0 comments on commit 42843e5

Please sign in to comment.