Accept near-complete frame extraction chunks
This commit is contained in:
@@ -126,7 +126,11 @@ def sample_video_frames(
|
||||
timeline_start_epoch=start_epoch,
|
||||
timezone_name=timezone_name,
|
||||
)
|
||||
if records and (max_frames is None or len(records) >= max_frames):
|
||||
if _has_usable_frames_after_nonzero_exit(
|
||||
records,
|
||||
max_frames=max_frames,
|
||||
ffmpeg_config=ffmpeg_config,
|
||||
):
|
||||
_attach_success_evidence(
|
||||
records,
|
||||
command,
|
||||
@@ -142,6 +146,24 @@ def sample_video_frames(
|
||||
return records
|
||||
|
||||
|
||||
def _has_usable_frames_after_nonzero_exit(
|
||||
records: list[dict[str, Any]],
|
||||
*,
|
||||
max_frames: int | None,
|
||||
ffmpeg_config: dict[str, Any],
|
||||
) -> bool:
|
||||
if not records:
|
||||
return False
|
||||
if max_frames is None or len(records) >= max_frames:
|
||||
return True
|
||||
min_ratio = float(ffmpeg_config.get("min_success_frame_ratio", 0.98))
|
||||
missing_tolerance = int(ffmpeg_config.get("max_missing_success_frames", 5))
|
||||
return (
|
||||
len(records) >= math.floor(max_frames * min_ratio)
|
||||
or max_frames - len(records) <= missing_tolerance
|
||||
)
|
||||
|
||||
|
||||
def _replace_video_records(
|
||||
manifest_path: Path,
|
||||
video_id: str,
|
||||
|
||||
Reference in New Issue
Block a user