|
@@ -92,6 +92,13 @@ class Source(): |
|
|
self._duration = 0.0 or float(subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", file])) |
|
|
self._duration = 0.0 or float(subprocess.check_output(["ffprobe", "-v", "error", "-show_entries", "format=duration", "-of", "default=noprint_wrappers=1:nokey=1", file])) |
|
|
return self._duration |
|
|
return self._duration |
|
|
|
|
|
|
|
|
|
|
|
def to_json(self): |
|
|
|
|
|
"""Return a dict representation of the source for JSON encoding |
|
|
|
|
|
|
|
|
|
|
|
@see video_producers.py:PipelineJSONEncoder |
|
|
|
|
|
""" |
|
|
|
|
|
return dict(source=self.source, path=self.path, provider=self.provider) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Interval(): |
|
|
class Interval(): |
|
@@ -113,6 +120,7 @@ class Interval(): |
|
|
# TODO: have default duration for intervals set by config |
|
|
# TODO: have default duration for intervals set by config |
|
|
# TODO: consider if we want to permit adjusting intervals (eg, start time, end time, duration) [probably yes] |
|
|
# TODO: consider if we want to permit adjusting intervals (eg, start time, end time, duration) [probably yes] |
|
|
# NOTE: if we have more ways of defining, we could consider multipledispatch? |
|
|
# NOTE: if we have more ways of defining, we could consider multipledispatch? |
|
|
|
|
|
# TODO: consider if we want to keep a reference to the media file (source) in the interval |
|
|
|
|
|
|
|
|
DEFAULT_DURATION = 5 # seconds |
|
|
DEFAULT_DURATION = 5 # seconds |
|
|
DEFAUT_PRECISION = 3 # decimal places |
|
|
DEFAUT_PRECISION = 3 # decimal places |
|
@@ -171,6 +179,13 @@ class Interval(): |
|
|
return self.end < other.end |
|
|
return self.end < other.end |
|
|
return self.start < other.start |
|
|
return self.start < other.start |
|
|
|
|
|
|
|
|
|
|
|
def to_json(self): |
|
|
|
|
|
"""Return a dict representation of the interval for JSON encoding |
|
|
|
|
|
|
|
|
|
|
|
@see video_producers.py:PipelineJSONEncoder |
|
|
|
|
|
""" |
|
|
|
|
|
return dict(start=self.start, end=self.end, duration=self.duration) |
|
|
|
|
|
|
|
|
# -------------------------------------------------------------- |
|
|
# -------------------------------------------------------------- |
|
|
# TODO: handle bad cases, eg negative duration, start > end, etc |
|
|
# TODO: handle bad cases, eg negative duration, start > end, etc |
|
|
# -------------------------------------------------------------- |
|
|
# -------------------------------------------------------------- |
|
@@ -261,3 +276,10 @@ class Feature(): |
|
|
return self.score < other.score |
|
|
return self.score < other.score |
|
|
return self.source < other.source |
|
|
return self.source < other.source |
|
|
return self.interval < other.interval |
|
|
return self.interval < other.interval |
|
|
|
|
|
def to_json(self): |
|
|
|
|
|
"""Return a dict representation of the feature for JSON encoding |
|
|
|
|
|
|
|
|
|
|
|
@see video_producers.py:PipelineJSONEncoder |
|
|
|
|
|
""" |
|
|
|
|
|
return dict(interval=self.interval.to_json(), source=self.source.to_json(), |
|
|
|
|
|
feature_extractor=self.feature_extractor, score=self.score) |