Main Content

vision.BinaryFileReader

Read video data from binary files

Description

The BinaryFileReader object reads video data from binary files.

To read a binary file:

  1. Create the vision.BinaryFileReader object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

example

bFileReader = vision.BinaryFileReader returns a binary file reader object, bFileReader, that reads binary video data from the specified file in I420 Four Character Code (FOURCC) video format.

bFileReader = vision.BinaryFileReader(Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, bFileReader = vision.BinaryFileReader('Filename','vipmen.bin')

bFileReader = vision.BinaryFileReader(file,Name,Value) returns a binary file reader System object, bFileReader, with the Filename property set to file and other specified properties set to the specified values.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

File name, specified as a character vector. The full path for the file needs to be specified only if the file is not on the MATLAB® path.

Video file format, specified as 'Four character codes' or 'Custom'.

Four Character Code video format, specified as one of the available video formats. For more information on four character codes, see https://en.wikipedia.org/wiki/FourCC. This property applies when you set the VideoFormat property to 'Four character codes'.

Format of data, specified as 'Planar' or 'Packed'.This property applies when you set the VideoFormat property to Custom.

Size of output, specified as an M-by-N matrix. This property applies when you set the BitstreamFormat property to 'Packed'.

Number of video components in video stream, specified as 1, 2, 3 or 4. This number corresponds to the number of video component outputs. This property applies when you set the VideoFormat property to 'Custom'.

Bit size of video components, specified as an integer vector of length N, where N is the value of the VideoComponentCount property. This property applies when you set the VideoFormat property to 'Custom'.

Size of video components, specified as an N-by-2 array, where N is the value of the VideoComponentCount property. Each row of the matrix corresponds to the size of that video component, with the first element denoting the number of rows and the second element denoting the number of columns. This property applies when you set the VideoFormat property to 'Custom' and the BitstreamFormat property to 'Planar'.

Order of video components, specified as a 1-by-N vector. This property must be set to a vector of length N, where N is set according to how you set the BitstreamFormat property. When you set the BitStreamFormat property to 'Planar', you must set N equal to the value of the VideoComponentCount property. Otherwise, you can set N equal to or greater than the value of the VideoComponentCount property. This property applies when you set the VideoFormat property to 'Custom'.

Interlaced video status, specified as true or false. Set this property to true if the video stream represents interlaced video data. This property applies when you set the VideoFormat property to 'Custom'.

Fill binary file format, specified as 'Top line first', or 'Bottom line first'. If you set this property to 'Top line first', the first row of the video frame gets filled first. If you set this property to 'Bottom line first', the last row of the video frame gets filled first.

Signed data, specified as true or false. Set this property to true for signed input data. This property applies when you set the VideoFormat property to 'Custom'

Byte order, specified as 'Little endian' or 'Big endian'. This property applies when you set the VideoFormat property to 'Custom'.

Play count for the number of times to play the file, specified as a positive integer.

Usage

Description

example

[Y,Cb,Cr] = bFileReader() reads the luminance, Y and chrominance, Cb and Cr components of a video stream from the specified binary file when you set the VideoFormat property to 'Four character codes'. Alternatively, it reads the values when you set the VideoFormat property to 'Custom' and the VideoComponentCount property to 2.

Y = bFileReader() reads the video component Y from the binary file when you set the VideoFormat property to 'Custom' and the VideoComponentCount property to 1.

[Y,Cb,Cr,Alpha] = bFileReader() additionally reads the Alpha when you set the VideoFormat property to 'Custom' and the VideoComponentCount property to 4.

[___,EOF] = bFileReader() also returns the end-of-file indicator, EOF. EOF is set to true when the output contains the last video frame in the file.

Output Arguments

expand all

Luminance value, returned as an M-by-N matrix.

Chrominance value, returned as an M-by-N matrix.

Chrominance value, returned as an M-by-N matrix.

Transparency value, returned as a scalar in the range [0,1].

Object Functions

To use an object function, specify the System object™ as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

isDoneEnd-of-file status (logical)
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a binary file reader and video player object.

hbfr = vision.BinaryFileReader();
hvp = vision.VideoPlayer;

Use the while loop to play the default video.

while ~isDone(hbfr)
y = hbfr();
hvp(y);
end

Close the input file and the video display.

release(hbfr);
release(hvp);

Version History

Introduced in R2012a