loop filler when our > duration

This commit is contained in:
jonathan 2021-07-22 17:07:08 +02:00
parent e302366f18
commit beb1031932
2 changed files with 12 additions and 11 deletions

View File

@ -33,7 +33,7 @@ import requests
from .filters.default import build_filtergraph
from .utils import (MediaProbe, check_sync, get_date, get_delta, get_float,
get_time, messenger, playlist, src_or_dummy, stdin_args,
storage, sync_op, valid_json)
sync_op, valid_json)
def handle_list_init(node):
@ -88,9 +88,9 @@ def handle_list_end(duration, node):
f'Last clip less then 1 second long, skip:\n{node["source"]}')
node = None
else:
missing_secs = abs(duration - (node['duration'] - node['seek']))
_, total_delta = get_delta(node['begin'])
messenger.error(
f'Playlist is not long enough:\n{missing_secs:.2f} seconds needed')
f'Playlist is not long enough:\n{total_delta:.2f} seconds needed')
out = node['out']
node = src_or_dummy(node)
@ -383,8 +383,7 @@ class GetSourceFromPlaylist:
'in': 0,
'seek': 0,
'out': duration,
'duration': duration + 1,
'source': storage.filler
'duration': duration + 1
}
self.generate_cmd()

View File

@ -874,18 +874,19 @@ def gen_filler(node):
if probe.format:
if probe.format.get('duration'):
filler_dur = float(probe.format['duration'])
if filler_dur > duration:
node['duration'] = float(probe.format['duration'])
node['source'] = storage.filler
if node['duration'] > duration:
# cut filler
messenger.info(
f'Generate filler with {duration:.2f} seconds')
node['source'] = storage.filler
node['src_cmd'] = ['-i', storage.filler] + set_length(
filler_dur, 0, duration)
node['duration'], 0, duration)
return node
# loop file n times
node['src_cmd'] = loop_input(storage.filler, filler_dur, duration)
node['src_cmd'] = loop_input(
storage.filler, node['duration'], duration)
return node
messenger.error("Can't get filler length, generate dummy!")
@ -939,7 +940,8 @@ def src_or_dummy(node):
['-i', node['source']] + set_length(node['duration'],
node['seek'], node['out'])
else:
messenger.error(f'File not exist: {node.get("source")}')
if 'source' in node:
messenger.error(f'File not exist: {node.get("source")}')
node = gen_filler(node)
return node