Write video frames and audio samples to video file
VideoFileWriter object writes video frames
and audio samples to a video file.
.mwv files can
be written only on Windows®. The video and audio can be compressed.
The available compression types depend on the encoders installed on
Note This block supports code generation for platforms that have file I/O available. You cannot use this block with Simulink® Desktop Real-Time™ software, because that product does not support file I/O.
This object performs best on platforms with Version 11 or later of Windows Media® Player software. This object supports only uncompressed RGB24 AVI files on Linux® and Mac platforms.
Windows 7 UAC (User Account Control), may require administrative
privileges to encode
The generated code for this object relies on prebuilt library
files. You can run this code outside the MATLAB® environment,
or redeploy it, but be sure to account for these extra library files
when doing so. The packNGo function creates a single zip file containing
all of the pieces required to run or rebuild this code. See
packNGo for more information.
To run an executable file that was generated from an object, you may need to add precompiled shared library files to your system path. See MATLAB Coder and Simulink Shared Library Dependencies for details.
This object allows you to write
to disk or across a network connection. Similarly, the
allows you to read
.wma/.wmv streams to disk or
across a network connection. If you want to play an
but you do not have the codecs, you can re-encode the file as
which is supported by the Computer Vision System Toolbox™.
videoFWriter = vision.VideoFileWriter returns
a video file writer System object,
It writes video frames to an uncompressed '
video file. Every call to the
step method writes
a video frame.
videoFWriter = vision.VideoFileWriter(FILENAME) returns
a video file writer object,
videoFWriter that writes
video to a file,
FILENAME. The file type can be
specified by the
videoFWriter = vision.VideoFileWriter(..., configures
the video file writer properties, specified as one or more name-value
pair arguments. Unspecified properties have default values.
|Code Generation Support|
|Supports MATLAB Function block: Yes|
|System Objects in MATLAB Code Generation|
|Generated code for this function uses a precompiled platform-specific shared library.|
|Code Generation Support, Usage Notes, and Limitations.|
Define and set up your video file writer object using the constructor.
step method with the optional
FILENAME, the video file writer
videoFWriter, and any optional properties.
See the syntax below for using the
step(videoFWriter,I) writes one frame of
I, to the output file. The input video
can be an M-by-N-by-3 truecolor
RGB video frame, or an M-by-N grayscale
step(videoFWriter,Y,Cb,Cr) writes one frame
of YCbCr 4:2:2 video. The width of Cb and Cr color components must
be half of the width of Y. You must set the value of the
step(videoFWriter,I,AUDIO) writes one frame
of the input video,
I, and one frame of audio
AUDIO, to the output file. This applies
when you set the
one frame of YCbCr 4:2:2 video, and one frame of audio samples,
to the output file. This applies when you set the
YCbCr 4:2:2'. The width of Cb and Cr color
components must be half of the width of Y.
Video output file name
Specify the name of the video file as a string. The file extension
you give for
Output file format
Specify the format of the file that is created. Supported formats and abbreviations:
Write audio data
Use this property to control whether the object writes audio
samples to the video file. Set this value to
Video frame rate
Specify the frame rate of the video data in frames per second as a positive numeric scalar.
For videos which also contain audio data, the rate of the audio
data will be determined as the rate of the video multiplied by the
number of audio samples passed in each invocation of the
Audio compression encoder
Specify the type of compression algorithm to implement for audio
data. This compression reduces the size of the video file. Choose
Video compression encoder
Specify the type of compression algorithm to use to compress
the video data. This compression reduces the size of the video file.
This property applies only when writing
Uncompressed audio data type
Specify the compressed output audio data type. This property
only applies when you write uncompressed
Color space for output file
Specify the color space of
Control size of output video file
Specify the output video quality as an integer in the range
Target ratio between number of bytes in input image and compressed image
Specify the compression factor as an integer greater than
Set up the reader and writer objects.
videoFReader = vision.VideoFileReader('viplanedeparture.mp4'); videoFWriter = vision.VideoFileWriter('myFile.avi','FrameRate',videoFReader.info.VideoFrameRate);
Write the first 50 frames from original file into a newly created AVI file.
for i=1:50 videoFrame = step(videoFReader); step(videoFWriter, videoFrame); end
Close the input and output files.