Main Content

vision.BinaryFileWriter

Write binary video data to files

Description

The BinaryFileWriter object writes binary video data to files.

To write binary data to a file:

  1. Create the vision.BinaryFileWriter 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

bFileWriter = vision.BinaryFileWriter returns a binary writer object that writes binary video data to an output file, output.bin in the I420 Four Character Code format.

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

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.

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://www.fourcc.org. 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.

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'.

Size of video components format, specified as 'Auto' or 'Property'. If this property is set to 'Auto', each component will have a VideoComponentBits property. 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'.

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 as 'Little endian' or 'Big endian'. This property applies when you set the VideoFormat property to 'Custom'.

Usage

Description

example

bFileWriter(Y,Cb,Cr) writes one frame of video to the specified output file. Y , Cb, Cr represent the luma (Y) and chroma (Cb and Cr) components of a video stream. This option applies when you set the VideoFormat property to 'Four character codes'.

bFileWriter(Y) writes video component Y to the output file when the VideoFormat property is set to 'Custom' and the VideoComponentCount property is set to 1.

bFileWriter(Y,Cb) writes video components Y and Cb to the output file when the VideoFormat property is 'Custom' and the VideoComponentCount property is set to 2.

bFileWriter(Y,Cb,Cr) writes video components Y , Cb and Cr to the output file when the VideoFormat property is set to 'Custom' and the VideoComponentCount property is set to 3.

bFileWriter(Y,Cb,Cr,Alpha) writes video components Y , Cb, Cr and Alpha to the output file when the VideoFormat property is set to 'Custom', and the VideoComponentCount property is set to 4.

Input 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

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

Set the output file name and create binary file reader and writer objects.

 filename = fullfile(tempdir,'output.bin');
 bFileReader = vision.BinaryFileReader;
 bFileWriter = vision.BinaryFileWriter(filename);

Write to the file.

 while ~isDone(bFileReader)
 	[y,cb,cr] = bFileReader();
 	bFileWriter(y,cb,cr);
 end

Close the files.

 release(bFileReader);
 release(bFileWriter);
Introduced in R2012a