don't create consecutive cuts with a length of less than 3 frames

This commit is contained in:
rolux 2013-07-26 14:29:36 +02:00
parent b19b7474a0
commit eff73f11fe
1 changed files with 9 additions and 1 deletions

View File

@ -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)