better and more simple time_shift
This commit is contained in:
parent
172f8ce6c2
commit
0e71a90ad7
@ -63,14 +63,16 @@ ffmpeg_copy_settings = ["-c", "copy", "-bsf:v", "h264_mp4toannexb", "-threads",
|
|||||||
# filler_path are for the GUI only at the moment
|
# filler_path are for the GUI only at the moment
|
||||||
# filler_clip get handle different, when a new length needs to calculate
|
# filler_clip get handle different, when a new length needs to calculate
|
||||||
# blackclip is for stream copy mode
|
# blackclip is for stream copy mode
|
||||||
|
|
||||||
# time_shift adds or subtract seconds to the clip start,
|
# time_shift adds or subtract seconds to the clip start,
|
||||||
# this is usefull for example for hls, because it have a big delay
|
# this is usefull for example for hls, because it have a big delay
|
||||||
# the value will be added to the clip begin
|
# the value will be added to the clip begin
|
||||||
# put 0 if you don't need it
|
# put 0 if you don't need it
|
||||||
|
|
||||||
# map_extension is only for special purpose,
|
# map_extension is only for special purpose,
|
||||||
# when your playlist have a different extension, then the originial clip
|
# when your playlist have a different extension, then the originial clip
|
||||||
# example: map_extension = [".mp4", ".mkv"]
|
# example: map_extension = [".mp4", ".mkv"]
|
||||||
# life blank for no change
|
# life blank for no change
|
||||||
[PLAYLIST]
|
[PLAYLIST]
|
||||||
playlist_path = /playlists
|
playlist_path = /playlists
|
||||||
clips_root = /ADtvMedia
|
clips_root = /ADtvMedia
|
||||||
@ -78,7 +80,7 @@ filler_path = /ADtvMedia/ADtv/03 - Musikalische Lückenfüller
|
|||||||
filler_clip = /ADtvMedia/ADtv/01 - Intro/seperator.clock.5-00.mp4
|
filler_clip = /ADtvMedia/ADtv/01 - Intro/seperator.clock.5-00.mp4
|
||||||
blackclip = /opt/dummy20.mkv
|
blackclip = /opt/dummy20.mkv
|
||||||
day_start = 6
|
day_start = 6
|
||||||
time_shift = -35
|
time_shift = 35
|
||||||
map_extension =
|
map_extension =
|
||||||
|
|
||||||
# buffer settings
|
# buffer settings
|
||||||
|
34
ffplayout.py
34
ffplayout.py
@ -78,7 +78,7 @@ _pre_comp = SimpleNamespace(
|
|||||||
|
|
||||||
_playlist = SimpleNamespace(
|
_playlist = SimpleNamespace(
|
||||||
path=cfg.get('PLAYLIST', 'playlist_path'),
|
path=cfg.get('PLAYLIST', 'playlist_path'),
|
||||||
start=cfg.getint('PLAYLIST', 'day_start'),
|
start=cfg.getfloat('PLAYLIST', 'day_start'),
|
||||||
filler=cfg.get('PLAYLIST', 'filler_clip'),
|
filler=cfg.get('PLAYLIST', 'filler_clip'),
|
||||||
blackclip=cfg.get('PLAYLIST', 'blackclip'),
|
blackclip=cfg.get('PLAYLIST', 'blackclip'),
|
||||||
shift=cfg.getint('PLAYLIST', 'time_shift'),
|
shift=cfg.getint('PLAYLIST', 'time_shift'),
|
||||||
@ -163,7 +163,7 @@ sys.stderr = ffplayout_logger(logger, logging.ERROR)
|
|||||||
|
|
||||||
# get time
|
# get time
|
||||||
def get_time(time_format):
|
def get_time(time_format):
|
||||||
t = datetime.today()
|
t = datetime.today() + timedelta(seconds=_playlist.shift)
|
||||||
if time_format == 'hour':
|
if time_format == 'hour':
|
||||||
return t.hour
|
return t.hour
|
||||||
elif time_format == 'full_sec':
|
elif time_format == 'full_sec':
|
||||||
@ -176,11 +176,12 @@ def get_time(time_format):
|
|||||||
|
|
||||||
# get date
|
# get date
|
||||||
def get_date(seek_day):
|
def get_date(seek_day):
|
||||||
|
d = date.today() + timedelta(seconds=_playlist.shift)
|
||||||
if get_time('hour') < _playlist.start and seek_day:
|
if get_time('hour') < _playlist.start and seek_day:
|
||||||
yesterday = date.today() - timedelta(1)
|
yesterday = d - timedelta(1)
|
||||||
return yesterday.strftime('%Y-%m-%d')
|
return yesterday.strftime('%Y-%m-%d')
|
||||||
else:
|
else:
|
||||||
return datetime.now().strftime('%Y-%m-%d')
|
return d.strftime('%Y-%m-%d')
|
||||||
|
|
||||||
|
|
||||||
# send error messages to email addresses
|
# send error messages to email addresses
|
||||||
@ -299,7 +300,7 @@ def src_or_dummy(src, duration, seek, out, dummy_len=None):
|
|||||||
# to see if we are sync
|
# to see if we are sync
|
||||||
def check_sync(begin):
|
def check_sync(begin):
|
||||||
time_now = get_time('full_sec')
|
time_now = get_time('full_sec')
|
||||||
start = float(_playlist.start * 3600) + _playlist.shift
|
start = float(_playlist.start * 3600)
|
||||||
tolerance = _buffer.tol * 2
|
tolerance = _buffer.tol * 2
|
||||||
|
|
||||||
t_dist = begin - time_now
|
t_dist = begin - time_now
|
||||||
@ -318,7 +319,7 @@ def check_sync(begin):
|
|||||||
# 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
|
||||||
def gen_input(src, begin, dur, seek, out, last):
|
def gen_input(src, begin, dur, seek, out, last):
|
||||||
start = float(_playlist.start * 3600) + _playlist.shift
|
start = float(_playlist.start * 3600)
|
||||||
day_in_sec = 86400.0
|
day_in_sec = 86400.0
|
||||||
ref_time = day_in_sec + start
|
ref_time = day_in_sec + start
|
||||||
time = get_time('full_sec')
|
time = get_time('full_sec')
|
||||||
@ -391,14 +392,14 @@ def is_float(value, text, convert):
|
|||||||
def check_last_item(src_cmd, last_time, last):
|
def check_last_item(src_cmd, last_time, last):
|
||||||
if None in src_cmd and not last:
|
if None in src_cmd and not last:
|
||||||
first = True
|
first = True
|
||||||
last_time = get_time('full_sec') + _playlist.shift
|
last_time = get_time('full_sec')
|
||||||
if 0 <= last_time < _playlist.start * 3600 + _playlist.shift:
|
if 0 <= last_time < _playlist.start * 3600:
|
||||||
last_time += 86400
|
last_time += 86400
|
||||||
|
|
||||||
elif 'lavfi' in src_cmd and not last:
|
elif 'lavfi' in src_cmd and not last:
|
||||||
first = True
|
first = True
|
||||||
last_time = get_time('full_sec') + _buffer.length + _buffer.tol
|
last_time = get_time('full_sec') + _buffer.length + _buffer.tol
|
||||||
if 0 <= last_time < _playlist.start * 3600 + _playlist.shift:
|
if 0 <= last_time < _playlist.start * 3600:
|
||||||
last_time += 86400
|
last_time += 86400
|
||||||
else:
|
else:
|
||||||
first = False
|
first = False
|
||||||
@ -444,7 +445,7 @@ def validate_thread(clip_nodes):
|
|||||||
# check if playlist is long enough
|
# check if playlist is long enough
|
||||||
last_begin = is_float(clip_nodes[-1].get('begin'), 0, True)
|
last_begin = is_float(clip_nodes[-1].get('begin'), 0, True)
|
||||||
last_duration = is_float(clip_nodes[-1].get('dur'), 0, True)
|
last_duration = is_float(clip_nodes[-1].get('dur'), 0, True)
|
||||||
start = float(_playlist.start * 3600) + _playlist.shift
|
start = float(_playlist.start * 3600)
|
||||||
total_play_time = last_begin + last_duration - start
|
total_play_time = last_begin + last_duration - start
|
||||||
|
|
||||||
if total_play_time < 86395.0:
|
if total_play_time < 86395.0:
|
||||||
@ -464,15 +465,14 @@ def exeption(message, dummy_len, path, last):
|
|||||||
src_cmd = gen_dummy(dummy_len)
|
src_cmd = gen_dummy(dummy_len)
|
||||||
|
|
||||||
if last:
|
if last:
|
||||||
last_time = float(_playlist.start * 3600 - 5) + _playlist.shift
|
last_time = float(_playlist.start * 3600 - 5)
|
||||||
first = False
|
first = False
|
||||||
else:
|
else:
|
||||||
last_time = (
|
last_time = (
|
||||||
get_time('full_sec') + dummy_len + _buffer.length + _buffer.tol
|
get_time('full_sec') + dummy_len + _buffer.length + _buffer.tol
|
||||||
+ _playlist.shift
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if 0 <= last_time < (_playlist.start + _playlist.shift) * 3600:
|
if 0 <= last_time < _playlist.start * 3600:
|
||||||
last_time += 86400
|
last_time += 86400
|
||||||
|
|
||||||
first = True
|
first = True
|
||||||
@ -527,7 +527,7 @@ def iter_src_commands():
|
|||||||
|
|
||||||
src = node_src
|
src = node_src
|
||||||
begin = is_float(
|
begin = is_float(
|
||||||
clip_node.get('begin'), last_time, True) + _playlist.shift
|
clip_node.get('begin'), last_time, True)
|
||||||
duration = is_float(clip_node.get('dur'), dummy_len, True)
|
duration = is_float(clip_node.get('dur'), dummy_len, True)
|
||||||
seek = is_float(clip_node.get('in'), 0, True)
|
seek = is_float(clip_node.get('in'), 0, True)
|
||||||
out = is_float(clip_node.get('out'), dummy_len, True)
|
out = is_float(clip_node.get('out'), dummy_len, True)
|
||||||
@ -569,7 +569,7 @@ def iter_src_commands():
|
|||||||
# set right values for new playlist
|
# set right values for new playlist
|
||||||
list_date = get_date(False)
|
list_date = get_date(False)
|
||||||
last_time = float(
|
last_time = float(
|
||||||
_playlist.start * 3600 - 5) + _playlist.shift
|
_playlist.start * 3600 - 5)
|
||||||
last_mod_time = 0.0
|
last_mod_time = 0.0
|
||||||
|
|
||||||
break
|
break
|
||||||
@ -582,7 +582,7 @@ def iter_src_commands():
|
|||||||
|
|
||||||
begin = get_time(
|
begin = get_time(
|
||||||
'full_sec'
|
'full_sec'
|
||||||
) + _buffer.length + _buffer.tol + _playlist.shift
|
) + _buffer.length + _buffer.tol
|
||||||
last = False
|
last = False
|
||||||
dummy_len = 60
|
dummy_len = 60
|
||||||
last_mod_time = 0.0
|
last_mod_time = 0.0
|
||||||
@ -596,7 +596,7 @@ def iter_src_commands():
|
|||||||
)
|
)
|
||||||
|
|
||||||
begin = get_time(
|
begin = get_time(
|
||||||
'full_sec') + _buffer.length + _buffer.tol + _playlist.shift
|
'full_sec') + _buffer.length + _buffer.tol
|
||||||
last = False
|
last = False
|
||||||
dummy_len = 60
|
dummy_len = 60
|
||||||
last_mod_time = 0.0
|
last_mod_time = 0.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user