Skip to content

VideoDecoder API accepts device argument as str or torch.device, but underlying C++ API add_video_stream only takes in a str. #602

@divyanshk

Description

@divyanshk

🐛 Describe the bug

Repro:

device = torch.device('cuda:0')
VideoDecoder(video, device=device)

fails with complaints that

trainer/0 [0]: Declaration: torchcodec_ns::add_video_stream(Tensor(a!) decoder, *, int? width=None, int? height=None, int? num_threads=None, str? dimension_order=None, int? stream_index=None, str? device=None) -> ()
trainer/0 [0]:Cast error details: Unable to cast Python instance of type <class 'torch.device'> to C++ type '?' (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)
trainer/0 [0]:Skipping video tensor([ 0,  0,  0,  ..., 49, 48, 48], dtype=torch.uint8) due to decoding error: torchcodec_ns::add_video_stream() Expected a value of type 'Optional[str]' for argument 'device' but instead found type 'device'.

VideoDecoder(video, device=str(self.device)) fixes the issue.

Versions

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions