Skip to content

Commit a9a570b

Browse files
committed
[scanner] Emit a log message when a new video is processed.
There was always a log message but it was only at debug verbosity. We should log one at info since it can help to identify what video is an issue when processing many at a time. Fixes: #213
1 parent ca71e7e commit a9a570b

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

dvr_scan/video_joiner.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ def __init__(self, paths: Union[AnyStr, List[AnyStr]], backend: str = "opencv"):
5555
paths = [paths]
5656
assert paths
5757
self._paths = paths
58+
self._path_index = 0
5859

5960
self._cap: Optional[VideoStream] = None
60-
self._curr_cap_index = 0
6161
self._total_frames: int = 0
6262
self._decode_failures: int = 0
6363
self._load_input_videos(backend)
@@ -105,17 +105,17 @@ def read(self, decode: bool = True) -> Optional[numpy.ndarray]:
105105
"""Read/decode the next frame."""
106106
next = self._cap.read(decode=decode)
107107
if next is False:
108-
if (self._curr_cap_index + 1) < len(self._paths):
109-
self._curr_cap_index += 1
108+
if (self._path_index + 1) < len(self._paths):
109+
self._path_index += 1
110110
# Compensate for presentation time of last frame
111111
self._position += 1
112112
self._decode_failures += (
113113
self._cap._decode_failures if hasattr(self._cap, "_decode_failures") else 0
114114
)
115-
logger.debug(
116-
"End of current video, loading next: %s" % self._paths[self._curr_cap_index]
115+
logger.info(
116+
f"Processing complete, opening next video: {self._paths[self._path_index]}"
117117
)
118-
self._cap = self._backend(self._paths[self._curr_cap_index])
118+
self._cap = self._backend(self._paths[self._path_index])
119119
self._last_cap_pos = self._cap.base_timecode
120120
return self.read(decode=decode)
121121
logger.debug("No more input to process.")
@@ -128,7 +128,7 @@ def read(self, decode: bool = True) -> Optional[numpy.ndarray]:
128128
def seek(self, target: FrameTimecode):
129129
"""Seek to the target offset. Only seeking forward is supported (i.e. `target` must be
130130
greater than the current `position`."""
131-
if len(self._paths) == 1 or self._curr_cap_index == 0 and target <= self._cap.duration:
131+
if len(self._paths) == 1 or self._path_index == 0 and target <= self._cap.duration:
132132
self._cap.seek(target)
133133
else:
134134
# TODO: This is ineffient if we have multiple input videos.

0 commit comments

Comments
 (0)