INNER CODE UNIT · Python

valid_media_file

ChenShuo2004/cs-board · webapp/server.py:563

def valid_media_file(path: Path) -> bool:
    if not path.exists() or path.stat().st_size < 1024:
        return False
    try:
        return probe_duration(path) > 0.1
    except Exception:
        return False


def valid_timed_video(path: Path, expected_ms: int, tolerance_seconds: float = 0.22) -> bool:
    """Reject stale scene clips whose old renderer added time past the narration."""
    if not valid_media_file(path):
        return False
    try:
        return abs(probe_duration(path) - expected_ms / 1000.0) <= tolerance_seconds
    except Exception:
        return False

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…