Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

read

Read video frame data from file

VideoReader.read will be removed in a future release. Use VideoReader.readFrame instead.

Syntax

  • video = read(v)
  • video = read(v,index)
    example
  • video = read(___,'native')

Description

video = read(v) reads all video frames from the file associated with v.

example

video = read(v,index) reads only the frames specified by index.

video = read(___,'native') returns data in the format specified by the VideoFormat property and can include any of the input arguments in the previous syntaxes.

Examples

collapse all

Select Video Frames to Read

Create a VideoReader object for the example movie file, xylophone.mp4.

v = VideoReader('xylophone.mp4');

Read only the first video frame.

video = read(v,1);

Read only the last video frame.

video = read(v,Inf);

Read frames 5 through 10.

video = read(v,[5 10]);

Read from the 50th frame to the end of the video file.

video = read(v,[50 Inf]);

Input Arguments

collapse all

v — Input VideoReader objectVideoReader object

Input VideoReader object. Use the VideoReader function to create a VideoReader object from your video file.

index — Frames to read[1 Inf] (default) | numeric scalar | two-element array

Frames to read, specified as a numeric scalar or a two-element array.

  • To read a single frame, specify a numeric scalar.

  • To read a range of frames, specify a two-element array.

The first frame number is 1, and Inf represents the last frame of the file.

Example: 10

Example: Inf

Example: [1 20]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

video — Video frame datanumeric array | structure array

Video frame data, returned as a numeric or structure array. The size and format of video depends on the VideoFormat property of v. When the VideoFormat property of v is 'Indexed' or 'Grayscale', the data type and dimensions of video depend on whether you call read with the 'native' argument. For most files, the data type and dimensions of video are as follows.

H is the image frame height, W is the image frame width, and F is the number of frames read.

Value of obj.VideoFormatData Type of videoDimensions of videoDescription
'RGB24', with or without specifying 'native'uint8

H-by-W-by-3-by-F

RGB24 image

'Grayscale', without specifying 'native'uint8

H-by-W-by-1-by-F

Grayscale image

'Indexed', without specifying 'native'uint8

H-by-W-by-3-by-F

RGB24 image

'Grayscale' or 'Indexed', specifying 'native'struct

1-by-F

MATLAB® movie, which is an array of frame structure arrays, each containing the fields cdata and colormap.

For Motion JPEG 2000 files, the data type and dimensions of video are as follows.

Value of obj.VideoFormatData Type of videoDimensions of videoDescription
'Mono8'uint8

H-by-W-by-1-by-F

Mono image

'Mono8 Signed'int8

H-by-W-by-1-by-F

Mono signed image

'Mono16'uint16

H-by-W-by-1-by-F

Mono image

'Mono16 Signed'int16

H-by-W-by-1-by-F

Mono signed image

'RGB24'uint8

H-by-W-by-3-by-F

RGB24 image

'RGB24 Signed'int8

H-by-W-by-3-by-F

RGB24 signed image

'RGB48'uint16

H-by-W-by-3-by-F

RGB48 image

'RGB48 Signed'int16

H-by-W-by-3-by-F

RGB48 signed image

See Also

|

Introduced in R2010b

Was this topic helpful?