mindspore.dataset.vision.DecodeVideo

class mindspore.dataset.vision.DecodeVideo[source]

Decode the input raw video bytes.

Supported video formats: AVI, H264, H265, MOV, MP4, WMV.

Raises
Supported Platforms:

CPU

Examples

>>> import numpy as np
>>> import mindspore.dataset as ds
>>> import mindspore.dataset.vision as vision
>>>
>>> # Use the transform in dataset pipeline mode
>>> # Custom class to generate and read video dataset
>>> class VideoDataset:
...     def __init__(self, file_list):
...         self.file_list = file_list
...
...     def __getitem__(self, index):
...         filename = self.file_list[index]
...         return np.fromfile(filename, np.uint8)
...
...     def __len__(self):
...         return len(self.file_list)
>>>
>>> dataset = ds.GeneratorDataset(VideoDataset(["/path/to/video/file"]), ["data"])
>>> decode_video = vision.DecodeVideo()
>>> dataset = dataset.map(operations=[decode_video], input_columns=["data"], output_columns=["video", "audio"])
>>>
>>> # Use the transform in eager mode
>>> filename = "/path/to/video/file"
>>> raw_ndarray = np.fromfile(filename, np.uint8)
>>> mindspore_output = vision.DecodeVideo()(raw_ndarray)