check duration

This commit is contained in:
j 2017-03-20 16:07:21 +00:00
parent 3fcaaf9081
commit fc1c7ec67f
1 changed files with 9 additions and 0 deletions

View File

@ -146,6 +146,15 @@ def get_clips(tag):
clip['duration'] = clip['out'] - clip['in']
clip['tag'] = tag
clips = [clip for clip in clips if clip['duration']]
for clip in clips:
fduration = ox.avinfo(clip['path'])['duration']
if clip['out'] > fduration:
if clip['in'] == 0:
clip['out'] = fduration
clip['duration'] = clip['out'] - clip['in']
else:
print('FAIL', clip, fduration)
sys.exit(1)
CLIPS[tag] = list(sorted(clips, key=lambda c: c['id']))
with open('CLIPS.json', 'w') as fd:
json.dump(CLIPS, fd, indent=4, sort_keys=True)