diff --git a/oxtimelines/timeline.py b/oxtimelines/timeline.py index aa45bf0..53e5c98 100644 --- a/oxtimelines/timeline.py +++ b/oxtimelines/timeline.py @@ -229,6 +229,7 @@ class Timelines(): self.detect_cuts = True self.cuts = [0] self.no_cuts = [] + self.short_cut = None self.cut_frames = [] self.max_cut_len = 15000 # 10 minutes self.max_distance = 64 * math.sqrt(3 * pow(255, 2)) @@ -395,10 +396,17 @@ class Timelines(): is_cut = False self.previous_distance = 0 else: + if self.short_cut and frame_i - self.short_cut > 2: + self.cuts.append(self.short_cut) + self.short_cut = None distance = self._get_distance(self.previous_frame_data, frame_data) is_cut = distance > 0.08 or (distance > 0.04 and abs(distance - self.previous_distance) > 0.04) if is_cut: - self.cuts.append(self.frame_i) + if frame_i - (0 if not self.cuts else self.short_cut or self.cuts[-1]) < 3: + is_cut = False + self.short_cut = frame_i + else: + self.cuts.append(self.frame_i) elif len(self.cut_frames) == self.max_cut_len: is_cut = True self.cuts.append(self.frame_i)