make sure all tracks are exactly the same length

This commit is contained in:
j 2024-12-04 09:16:24 +00:00
commit b2552d6059
3 changed files with 78 additions and 22 deletions

View file

@ -23,6 +23,9 @@ def resolve_roman(s):
return s.replace(extra, new)
return s
def format_duration(duration, fps):
return float('%0.5f' % (round(duration * fps) / fps))
class Command(BaseCommand):
help = 'generate symlinks to clips and clips.json'
@ -68,6 +71,10 @@ class Command(BaseCommand):
if not clip["duration"]:
print('!!', durations, clip)
continue
cd = format_duration(clip["duration"], 24)
#if cd != clip["duration"]:
# print(clip["duration"], '->', cd, durations, clip)
clip["duration"] = cd
clip['tags'] = i.data.get('tags', [])
clip['editingtags'] = i.data.get('editingtags', [])
name = os.path.basename(clip['original'])
@ -117,7 +124,7 @@ class Command(BaseCommand):
subs.append(sdata)
voice_over[fragment_id][batch] = {
"src": target,
"duration": source.duration,
"duration": format_duration(source.duration, 24),
"subs": subs
}
with open(os.path.join(prefix, 'voice_over.json'), 'w') as fd: