From eff73f11fe03fb1ea1fc68f4e78e0fc08f783d83 Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 26 Jul 2013 14:29:36 +0200 Subject: [PATCH] don't create consecutive cuts with a length of less than 3 frames --- oxtimelines/timeline.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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)