feat: minor chanes to highlight
This commit is contained in:
parent
f6f8e3ca8f
commit
83041a44d1
Binary file not shown.
1436
result.csv
1436
result.csv
File diff suppressed because it is too large
Load Diff
|
|
@ -78,10 +78,20 @@ class VideoHighlighter:
|
|||
df["start"] = df["start"].apply(self._to_seconds)
|
||||
df["end"] = df["end"].apply(self._to_seconds)
|
||||
|
||||
# Добавить проверку валидности
|
||||
invalid = df[df["start"] >= df["end"]]
|
||||
if not invalid.empty:
|
||||
raise ValueError("Найдены некорректные интервалы: start >= end")
|
||||
|
||||
raw = list(df.sort_values("start")[
|
||||
["start", "end"]].itertuples(index=False, name=None))
|
||||
merged = self._merge_intervals(raw)
|
||||
return self._add_padding(merged, total_dur=self._get_duration())
|
||||
|
||||
# Получить длительность один раз
|
||||
with VideoFileClip(str(self.video)) as v:
|
||||
total_dur = v.duration
|
||||
|
||||
return self._add_padding(merged, total_dur=total_dur)
|
||||
|
||||
def _merge_intervals(self, intervals: List[Tuple[float, float]]) -> List[Tuple[float, float]]:
|
||||
if not intervals:
|
||||
|
|
@ -111,7 +121,8 @@ class VideoHighlighter:
|
|||
fname = self.out_dir / f"clip_{idx:02d}.mp4"
|
||||
self._save_clip(clip, fname)
|
||||
clip.close()
|
||||
clips.append(clip)
|
||||
else:
|
||||
clips.append(clip) # Добавляем только если concat=True
|
||||
return clips
|
||||
|
||||
def _save_clip(self, clip: VideoFileClip, fname: Path) -> None:
|
||||
|
|
|
|||
Loading…
Reference in New Issue