Skip to content

get_safe_default_video_backend picks torchcodec when installed but unloadable (missing FFmpeg shared libraries) #4176

Description

@ahmedsohail2003

Description

get_safe_default_video_backend() promotes torchcodec to the default video backend whenever importlib.util.find_spec("torchcodec") succeeds. But installed is not the same as loadable: torchcodec links against FFmpeg shared libraries at runtime, which are commonly absent on Windows (and on minimal Linux images). find_spec still sees the package, the default becomes torchcodec, and every dataset video decode then crashes with a DLL-load RuntimeError unless the user knows to pass video_backend="pyav" explicitly.

Reproduction

  1. Windows machine without FFmpeg shared libraries on PATH
  2. pip install "lerobot[dataset]" (installs the torchcodec wheel fine)
  3. Load any video dataset with defaults: LeRobotDataset("lerobot/pusht")[0]
  4. Crash at first decode; workaround is video_backend="pyav"

Expected behavior

The safe default should verify the backend actually loads (e.g., probe torchcodec.decoders, which decoding imports anyway) and fall back to pyav with an actionable warning. PR attached.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn’t working correctlydatasetIssues regarding data inputs, processing, or datasetsdependenciesConcerns about external packages, libraries, or versioning

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions