Main Content

vision.BinaryFileWriter

Write binary video data to files

Description

TheBinaryFileWriterobject writes binary video data to files.

To write binary data to a file:

  1. Create thevision.BinaryFileWriterobject and set its properties.

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

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

Creation

Description

example

bFileWriter= vision.BinaryFileWriterreturns a binary writer object that writes binary video data to an output file,output.binin theI420Four 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 arenontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and thereleasefunction unlocks them.

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

For more information on changing property values, seeSystem 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, seehttps://en.wikipedia.org/wiki/FourCC. This property applies when you set theVideoFormatproperty to'Four character codes'.

Format of data, specified as'Planar'or'Packed'.This property applies when you set theVideoFormatproperty toCustom.

Number of video components in video stream, specified as1,2,3or4. This number corresponds to the number of video component outputs. This property applies when you set theVideoFormatproperty to'Custom'.

Size of video components format, specified as'Auto'or 'Property'. If this property is set to'Auto', each component will have aVideoComponentBits财产。This property applies when you set theVideoFormatproperty to'Custom'.

Bit size of video components, specified as an integer vector of lengthN, whereNis the value of theVideoComponentCount财产。This property applies when you set theVideoFormatproperty to'Custom'.

Order of video components, specified as a 1-by-Nvector. This property must be set to a vector of lengthN, whereNis set according to how you set theBitstreamFormat财产。When you set theBitStreamFormatproperty to'Planar', you must setNequal to the value of theVideoComponentCount财产。其他wise, you can setNequal to or greater than the value of theVideoComponentCount财产。This property applies when you set theVideoFormatproperty to'Custom'.

Interlaced video status, specified astrueorfalse. Set this property totrueif the video stream represents interlaced video data. This property applies when you set theVideoFormatproperty 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'最后一行的视频帧冷杉填充t.

Signed data, specified astrueorfalse. Set this property totruefor signed input data. This property applies when you set theVideoFormatproperty to'Custom'

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

Usage

Description

example

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

bFileWriter(Y)writes video componentYto the output file when theVideoFormatproperty is set to'Custom'and theVideoComponentCountproperty is set to1.

bFileWriter(Y,Cb)writes video componentsYandCbto the output file when theVideoFormatproperty is'Custom'and theVideoComponentCountproperty is set to2.

bFileWriter(Y,Cb,Cr)writes video componentsY,CbandCrto the output file when theVideoFormatproperty is set to'Custom'and theVideoComponentCountproperty is set to3.

bFileWriter(Y,Cb,Cr,Alpha)writes video componentsY,Cb,CrandAlphato the output file when theVideoFormatproperty is set to'Custom', and theVideoComponentCountproperty is set to4.

Input Arguments

expand all

Luminance value, returned as anM-by-Nmatrix.

Chrominance value, returned as anM-by-Nmatrix.

Chrominance value, returned as anM-by-Nmatrix.

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 namedobj, use this syntax:

release(obj)

expand all

step RunSystem objectalgorithm
release Release resources and allow changes toSystem objectproperty values and input characteristics
reset Reset internal states ofSystem 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);

Version History

Introduced in R2012a