scene detection quality and caching
This commit is contained in:
@@ -12,7 +12,9 @@ logger = logging.getLogger(__name__)
|
||||
class CacheManager:
|
||||
"""Manage caching of intermediate processing results."""
|
||||
|
||||
def __init__(self, output_dir: Path, frames_dir: Path, video_name: str, use_cache: bool = True):
|
||||
def __init__(self, output_dir: Path, frames_dir: Path, video_name: str, use_cache: bool = True,
|
||||
skip_cache_frames: bool = False, skip_cache_whisper: bool = False,
|
||||
skip_cache_analysis: bool = False):
|
||||
"""
|
||||
Initialize cache manager.
|
||||
|
||||
@@ -20,12 +22,18 @@ class CacheManager:
|
||||
output_dir: Output directory for cached files
|
||||
frames_dir: Directory for cached frames
|
||||
video_name: Name of the video (stem)
|
||||
use_cache: Whether to use caching
|
||||
use_cache: Whether to use caching globally
|
||||
skip_cache_frames: Skip cached frames specifically
|
||||
skip_cache_whisper: Skip cached whisper specifically
|
||||
skip_cache_analysis: Skip cached analysis specifically
|
||||
"""
|
||||
self.output_dir = output_dir
|
||||
self.frames_dir = frames_dir
|
||||
self.video_name = video_name
|
||||
self.use_cache = use_cache
|
||||
self.skip_cache_frames = skip_cache_frames
|
||||
self.skip_cache_whisper = skip_cache_whisper
|
||||
self.skip_cache_analysis = skip_cache_analysis
|
||||
|
||||
def get_whisper_cache(self) -> Optional[Path]:
|
||||
"""
|
||||
@@ -34,7 +42,7 @@ class CacheManager:
|
||||
Returns:
|
||||
Path to cached transcript or None
|
||||
"""
|
||||
if not self.use_cache:
|
||||
if not self.use_cache or self.skip_cache_whisper:
|
||||
return None
|
||||
|
||||
cache_path = self.output_dir / f"{self.video_name}.json"
|
||||
@@ -51,7 +59,7 @@ class CacheManager:
|
||||
Returns:
|
||||
List of (frame_path, timestamp) tuples or None
|
||||
"""
|
||||
if not self.use_cache or not self.frames_dir.exists():
|
||||
if not self.use_cache or self.skip_cache_frames or not self.frames_dir.exists():
|
||||
return None
|
||||
|
||||
existing_frames = list(self.frames_dir.glob("frame_*.jpg"))
|
||||
@@ -84,7 +92,7 @@ class CacheManager:
|
||||
Returns:
|
||||
List of analysis results or None
|
||||
"""
|
||||
if not self.use_cache:
|
||||
if not self.use_cache or self.skip_cache_analysis:
|
||||
return None
|
||||
|
||||
cache_path = self.output_dir / f"{self.video_name}_{analysis_type}.json"
|
||||
|
||||
Reference in New Issue
Block a user