Skip to content

Make read_video/write_video support Path from pathlib #7721

Open
@RafailFridman

Description

@RafailFridman

🚀 The feature

Currently, read_video method from torchvision.io accepts only a string as its first argument. I suggest making it work also with the Path object from pathlib library.
Like this:

from pathlib import Path
root = Path("videos")
video = read_video(root/"video.mp4", pts_unit="sec")[0]

Currently, it raises ValueError: File object has no read() method, or readable() returned False.

Motivation, pitch

Working with paths as strings is not convenient, and instead, people are using Path from pathlib.

Alternatives

No response

Additional context

No response

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