Skip to content

Research cheapest reliable way to read video duration #192

Description

Context

We need a cheap, reliable way to determine video length without deriving it from frame-processing workflows. Duration should be available before or independently of frame extraction so planning, validation, and accounting do not require expensive decode work.

Goal

Inspect the best implementation path for getting video duration with minimal compute, IO, dependency, and operational cost.

Questions to answer

  • Can we read duration from container metadata only, avoiding frame decode entirely?
  • Which backend/tooling is the best fit for this package: ffprobe, PyAV/FFmpeg bindings, OpenCV metadata, MediaInfo, cloud/object-store metadata, or another approach?
  • What are the failure modes for common formats/codecs, variable frame rate videos, truncated files, remote files, and missing/incorrect metadata?
  • What is the cheapest acceptable fallback when metadata is unavailable or untrusted?
  • How should this integrate with existing readers/processors/pipeline semantics without coupling duration lookup to frame extraction?

Evaluation criteria

  • Avoids decoding frames in the common path.
  • Minimizes bytes read for local and remote inputs.
  • Has predictable dependency and packaging implications.
  • Handles common video containers accurately enough for pipeline planning.
  • Exposes clear errors or fallback behavior when duration cannot be determined cheaply.

Deliverable

Propose an implementation approach, including dependency choice, API placement, fallback behavior, tests, and documentation updates. Compare the approach with how Spark, Beam/Dataflow, Daft, Hugging Face Datasets, and Ray/Ray Data would typically treat this kind of metadata extraction, and justify any deviation for this codebase.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions