framereader index data as param

pull/1474/head
Greg Hogan 5 years ago
parent 28128cbbeb
commit 0b5758f1be
  1. 12
      tools/lib/framereader.py

@ -115,8 +115,11 @@ def vidindex(fn, typ):
def cache_fn(func): def cache_fn(func):
@wraps(func) @wraps(func)
def cache_inner(fn, *args, **kwargs): def cache_inner(fn, *args, **kwargs):
cache_prefix = kwargs.pop('cache_prefix', None) if kwargs.pop('no_cache', None):
cache_path = cache_path_for_file_path(fn, cache_prefix) cache_path = None
else:
cache_prefix = kwargs.pop('cache_prefix', None)
cache_path = cache_path_for_file_path(fn, cache_prefix)
if cache_path and os.path.exists(cache_path): if cache_path and os.path.exists(cache_path):
with open(cache_path, "rb") as cache_file: with open(cache_path, "rb") as cache_file:
@ -543,12 +546,13 @@ class BaseFrameReader(object):
def get(self, num, count=1, pix_fmt="yuv420p"): def get(self, num, count=1, pix_fmt="yuv420p"):
raise NotImplementedError raise NotImplementedError
def FrameReader(fn, cache_prefix=None, readahead=False, readbehind=False, multithreaded=True): def FrameReader(fn, cache_prefix=None, readahead=False, readbehind=False, multithreaded=True, index_data=None):
frame_type = fingerprint_video(fn) frame_type = fingerprint_video(fn)
if frame_type == FrameType.raw: if frame_type == FrameType.raw:
return RawFrameReader(fn) return RawFrameReader(fn)
elif frame_type in (FrameType.h265_stream, FrameType.h264_pstream): elif frame_type in (FrameType.h265_stream, FrameType.h264_pstream):
index_data = get_video_index(fn, frame_type, cache_prefix) if not index_data:
index_data = get_video_index(fn, frame_type, cache_prefix)
if index_data is not None and "predecom" in index_data: if index_data is not None and "predecom" in index_data:
cache_path = cache_path_for_file_path(fn, cache_prefix) cache_path = cache_path_for_file_path(fn, cache_prefix)
return MKVFrameReader( return MKVFrameReader(

Loading…
Cancel
Save