rewrite gen_input function
This commit is contained in:
parent
3268fe0b0e
commit
a630b6a777
111
ffplayout.py
111
ffplayout.py
@ -638,68 +638,77 @@ def gen_input(src, begin, dur, seek, out, last):
|
|||||||
check begin and length from clip
|
check begin and length from clip
|
||||||
return clip only if we are in 24 hours time range
|
return clip only if we are in 24 hours time range
|
||||||
"""
|
"""
|
||||||
day_in_sec = 86400.0
|
|
||||||
ref_time = day_in_sec
|
|
||||||
current_time = get_time('full_sec')
|
|
||||||
|
|
||||||
if _playlist.start:
|
if not _playlist.start:
|
||||||
ref_time = day_in_sec + _playlist.start
|
|
||||||
|
|
||||||
if 0 <= current_time < _playlist.start:
|
|
||||||
current_time += day_in_sec
|
|
||||||
|
|
||||||
# calculate time difference to see if we are sync
|
|
||||||
time_diff = out - seek + current_time
|
|
||||||
|
|
||||||
if ((time_diff <= ref_time or begin < day_in_sec) and not last) \
|
|
||||||
or not _playlist.start:
|
|
||||||
# when we are in the 24 houre range, get the clip
|
|
||||||
return src_or_dummy(src, dur, seek, out), None
|
return src_or_dummy(src, dur, seek, out), None
|
||||||
elif time_diff < ref_time and last:
|
else:
|
||||||
# when last clip is passed and we still have too much time left
|
ref_time = 86400.0 + _playlist.start
|
||||||
# check if duration is larger then out - seek
|
new_seek = 0
|
||||||
time_diff = dur + current_time
|
|
||||||
new_len = dur - (time_diff - ref_time)
|
|
||||||
|
|
||||||
if time_diff >= ref_time:
|
if begin + (out - seek) < ref_time:
|
||||||
messenger.info('we are under time, new_len is: {0:.2f}'.format(
|
if not last:
|
||||||
new_len))
|
# when we are in the 24 houre range, get the clip
|
||||||
src_cmd = src_or_dummy(src, dur, 0, new_len)
|
return src_or_dummy(src, dur, seek, out), None
|
||||||
else:
|
else:
|
||||||
src_cmd = src_or_dummy(src, dur, 0, dur)
|
# when last clip is reached and we under ref_time,
|
||||||
|
# check if out/duration is long enough
|
||||||
|
if out >= dur and begin + out > ref_time:
|
||||||
|
new_len = begin + out - ref_time
|
||||||
|
elif begin + dur > ref_time:
|
||||||
|
new_len = begin + dur - ref_time
|
||||||
|
else:
|
||||||
|
missing_secs = abs(begin + out - ref_time)
|
||||||
|
messenger.error(
|
||||||
|
'Playlist is not long enough:'
|
||||||
|
'\n{0:.2f} seconds needed.'.format(missing_secs))
|
||||||
|
|
||||||
messenger.error(
|
src_cmd = src_or_dummy(src, dur, 0, dur)
|
||||||
'Playlist is not long enough:\n{0:.2f} seconds needed.'.format(
|
return src_cmd, missing_secs
|
||||||
|
|
||||||
|
messenger.info('we are under time, new_len is: {0:.2f}'.format(
|
||||||
new_len))
|
new_len))
|
||||||
|
|
||||||
return src_cmd, new_len - dur
|
if seek > 0:
|
||||||
|
new_seek = out - new_len
|
||||||
|
new_len = out
|
||||||
|
|
||||||
elif time_diff > ref_time:
|
src_cmd = src_or_dummy(src, dur, new_seek, new_len)
|
||||||
new_len = out - seek - (time_diff - ref_time)
|
return src_cmd, 0.0
|
||||||
# when we over the 24 hours range, trim clip
|
|
||||||
messenger.info('we are over time, new_len is: {0:.2f}'.format(new_len))
|
|
||||||
|
|
||||||
# When calculated length from last clip is longer then 5 seconds,
|
elif begin > ref_time:
|
||||||
# we use the clip. When the length is less then 5 and bigger then 1
|
messenger.info(
|
||||||
# second we generate a black clip and when is less the a seconds
|
'start time is over 24 hours, skip clip:\n{}'.format(src))
|
||||||
# we skip the clip.
|
return None, 0.0
|
||||||
if new_len > 5.0:
|
|
||||||
new_seek = 0
|
|
||||||
|
|
||||||
if seek > 0:
|
elif begin + (out - seek) > ref_time:
|
||||||
new_len = out
|
# when we over the 24 hours range, trim clip
|
||||||
new_seek = out - new_len
|
new_len = begin + (out - seek) - ref_time
|
||||||
|
|
||||||
|
# When calculated length from last clip is longer then 5 seconds,
|
||||||
|
# we use the clip. When the length is less then 5 and bigger then 1
|
||||||
|
# second we generate a black clip and when is less the a seconds
|
||||||
|
# we skip the clip.
|
||||||
|
if new_len > 5.0:
|
||||||
|
messenger.info(
|
||||||
|
'we are over time, new_len is: {0:.2f}'.format(new_len))
|
||||||
|
new_seek = 0
|
||||||
|
|
||||||
|
if seek > 0:
|
||||||
|
new_seek = out - new_len
|
||||||
|
new_len = out
|
||||||
|
|
||||||
|
src_cmd = src_or_dummy(src, dur, new_seek, new_len)
|
||||||
|
elif new_len > 1.0:
|
||||||
|
src_cmd = gen_dummy(new_len)
|
||||||
|
else:
|
||||||
|
messenger.info(
|
||||||
|
'last clip less then a second long, skip:\n{}'.format(src))
|
||||||
|
src_cmd = None
|
||||||
|
|
||||||
|
return src_cmd, 0.0
|
||||||
|
|
||||||
src_cmd = src_or_dummy(src, dur, new_seek, new_len)
|
|
||||||
elif new_len > 1.0:
|
|
||||||
src_cmd = gen_dummy(new_len)
|
|
||||||
else:
|
else:
|
||||||
src_cmd = None
|
return None, 0.0
|
||||||
|
|
||||||
return src_cmd, 0.0
|
|
||||||
|
|
||||||
else:
|
|
||||||
return None, 0.0
|
|
||||||
|
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user