print warning if clips are to short
This commit is contained in:
parent
b056c298a6
commit
0708521a0f
2 changed files with 12 additions and 26 deletions
31
edit.py
31
edit.py
|
@ -147,6 +147,7 @@ if __name__ == '__main__':
|
|||
credentials = ox.web.auth.get(site)
|
||||
except:
|
||||
credentials = {}
|
||||
print('Please provide your username and password for %s:' % site)
|
||||
credentials['username'] = input('Username: ')
|
||||
credentials['password'] = getpass.getpass('Password: ')
|
||||
ox.web.auth.update(site, credentials)
|
||||
|
@ -157,7 +158,8 @@ if __name__ == '__main__':
|
|||
for kv in r['data']['errors'].items():
|
||||
print('%s: %s' % kv)
|
||||
sys.exit(1)
|
||||
print('Edit:', edit_id, 'Sort:', sort_by)
|
||||
print('Edit:', edit_id)
|
||||
print('Sort:', sort_by)
|
||||
r = api.getEdit(id=edit_id)
|
||||
if 'data' not in r:
|
||||
print(r)
|
||||
|
@ -182,16 +184,19 @@ if __name__ == '__main__':
|
|||
|
||||
part_pos = 0
|
||||
for i, duration in enumerate(clip['durations']):
|
||||
stream_out = stream_in = None
|
||||
if part_pos + duration < clip['in']:
|
||||
part_pos += duration
|
||||
elif part_pos <= clip['in']:
|
||||
stream_in = clip['in'] - part_pos
|
||||
stream_out = min(clip['out'] - part_pos, duration)
|
||||
elif clip['out'] > part_pos:
|
||||
stream_in = 0
|
||||
stream_out = min(clip['out'] - part_pos, duration)
|
||||
|
||||
if stream_in is not None and stream_out is not None:
|
||||
stream_in = math.ceil(stream_in / (1/25)) * 1/25
|
||||
stream_out = math.ceil(stream_out / (1/25)) * 1/25
|
||||
|
||||
part_pos += duration
|
||||
info = get_info(api, clip['streams'][i], clip['item'], i+1)
|
||||
if stream_out > stream_in:
|
||||
videos.append({
|
||||
|
@ -207,27 +212,7 @@ if __name__ == '__main__':
|
|||
videos[-1]['path'] = os.path.join(prefix, info['path'])
|
||||
if clip_subtitles:
|
||||
videos[-1]['subtitles'] = '\n'.join(clip_subtitles)
|
||||
elif clip['out'] > part_pos:
|
||||
stream_in = 0
|
||||
stream_out = min(clip['out'] - part_pos, duration)
|
||||
stream_in = math.ceil(stream_in / (1/25)) * 1/25
|
||||
stream_out = math.ceil(stream_out / (1/25)) * 1/25
|
||||
part_pos += duration
|
||||
info = get_info(api, clip['streams'][i], clip['item'], i+1)
|
||||
if stream_out > stream_in:
|
||||
videos.append({
|
||||
'oshash': clip['streams'][i],
|
||||
'url': '%s/%s/%sp%s.mp4' % (base_url, clip['item'], stream_resolution, i),
|
||||
'resolution': info['resolution'],
|
||||
'item': clip['item'],
|
||||
'annotation': clip.get('annotation'),
|
||||
'in': stream_in,
|
||||
'out': stream_out,
|
||||
})
|
||||
if 'path' in info:
|
||||
videos[-1]['path'] = os.path.join(prefix, info['path'])
|
||||
if clip_subtitles:
|
||||
videos[-1]['subtitles'] = '\n'.join(clip_subtitles)
|
||||
|
||||
position += clip['duration']
|
||||
position = math.ceil(position / (1/25)) * 1/25
|
||||
|
|
|
@ -61,7 +61,7 @@ for clip in edit:
|
|||
files.append(out)
|
||||
src_duration = clip['out']-clip['in']
|
||||
if abs(src_duration-duration) > 1:
|
||||
print(clip.get('annotation', clip['item']), src_duration, duration)
|
||||
print(clip.get('annotation', clip['item']), 'expected', src_duration, 'got', duration, out)
|
||||
if clip.get('subtitles'):
|
||||
subtitles.append({
|
||||
'in': position,
|
||||
|
@ -128,7 +128,9 @@ for clip in edit:
|
|||
print('try again?:')
|
||||
print(' '.join(cmd).replace('-nostats -loglevel error', ''))
|
||||
sys.exit(1)
|
||||
print(clip, duration, clip['out']-clip['in'])
|
||||
src_duration = clip['out']-clip['in']
|
||||
if abs(src_duration-duration) > 1:
|
||||
print(clip.get('annotation', clip['item']), 'expected', src_duration, 'got', duration, out)
|
||||
if clip.get('subtitles'):
|
||||
subtitles.append({
|
||||
'in': position,
|
||||
|
@ -136,7 +138,6 @@ for clip in edit:
|
|||
'value': clip['subtitles']
|
||||
})
|
||||
position += duration
|
||||
print(out, duration, (clip['out'] - clip['in']))
|
||||
|
||||
txt = output + '.txt'
|
||||
with open(txt, 'w') as fd:
|
||||
|
|
Loading…
Reference in a new issue