signalblks.MultimediaFileWriter class

Package: signalblks

Write video frames, audio samples, or both to multimedia file

    Note:   MultimediaFileWriter will be removed in a future release. Use AudioFileWriter instead. See dsp.AudioFileWriter.

Description

The MultimediaFileWriter object writes video frames, audio samples, or both to a multimedia file.

To write video frames, audio samples, or both to a multimedia file:

  1. Define and set up your multimedia file writer. See Construction.

  2. Call step to write to a multimedia file according to the properties of signalblks.MultimediaFileWriter. The behavior of step is specific to each object in the toolbox.

Construction

H = signalblks.MultimediaFileWriter returns a multimedia file writer System object™, H, that writes video frames, audio samples, or both to a multimedia file (such as an AVI file).

H = signalblks.MultimediaFileWriter('PropertyName',PropertyValue,...) returns a multimedia file writer System object, H, with each specified property set to the specified value.

H = signalblks.MultimediaFileWriter(FILENAME,'PropertyName',PropertyValue,...) returns a multimedia file writer System object, H, with Filename property set to FILENAME and other specified properties set to the specified values.

Properties

Filename

Name of multimedia file to which to write

Specify the name of the multimedia file as a string. The default is output.avi.

FileFormat

Multimedia file format

Specify which multimedia file format the object writes. On Microsoft® platforms, select AVI, WAV, WMV, or WMA. These abbreviations correspond to the following file formats:

  • WAV: Microsoft WAVE Files

  • WMV: Windows Media® Video

  • WMA: Windows Media Audio

  • AVI: Audio-Video Interleave

The default setting for this property is AVI.

On all other platforms, the only selection is AVI.

AudioInputPort

Choose to write audio data

Use this property to specify whether the multimedia file writer object writes audio samples to a multimedia file. When you enable both this property and VideoInputPort, ensure that the video and audio input signals have the same frame period. Adjust the frame size (or number of rows) of the audio signal so that the frame period of the video signal is the same as the frame period of the audio signal. Calculate frame size by dividing the audio signal frequency by the frame rate of the video signal. The audio signal frequency is in samples per second (specified by SampleRate). The video signal frame rate is in frames per second (specified by FrameRate). The default selection for this property is true.

The multimedia file object takes a column vector as an input. Every column is a separate channel and each row corresponds to a single audio sample.

VideoInputPort

Choose to write video data

Use this property to specify whether the multimedia file writer object writes video frames to a multimedia file. When you enable both this property and the AudioInputPort property, ensure that the video and audio input signals have the same frame period. Adjust frame size (or number of rows) for the audio signal so the frame period is equal of both the video signal and the audio signal. Calculate frame size by dividing the audio signal frequency by the frame rate of the video signal. The audio signal frequency is in samples per second (specified by SampleRate). The video signal frame rate is in frames per second (specified by FrameRate). The default selection for this property is false

AudioCompressor

Algorithm that compresses audio data

Specify the type of compression algorithm the multimedia file writer uses to compress the audio data. Compression reduces the size of the multimedia file. Select None (uncompressed) to save uncompressed audio data to a multimedia file. The other options available reflect the audio compression algorithms installed on your system. This property is only available when writing WAV or AVI files on Windows® platforms.

VideoCompressor

Algorithm that compresses video data

Specify the type of compression algorithm to multimedia file writer uses to compress the video data. This compression reduces the size of the multimedia file. Choose None (uncompressed) to save uncompressed video data to a multimedia file. The other options reflect the available video compression algorithms installed on your system. This property is only available when writing AVI files on Windows platforms.

SampleRate

Sampling rate of audio data stream

Specify the sampling rate of the input audio data as a positive numeric scalar. The default is 44100. This property only applies when you set the AudioInputPort property to true.

FrameRate

Frame rate of video data stream

Specify the frame rate of the video data in frames per second as a positive numeric scalar. The default is 30. This property only applies when you set the VideoInputPort property to true.

AudioDataType

Data type of the uncompressed audio

Specify the type of uncompressed audio data written to the file. This property only applies when writing uncompressed WAV files.

FileColorSpace

Color space to use when creating a file

Specify the color space of AVI files as RGB or YCbCr 4:2:2. This property only applies on Windows platforms when you set the FileFormat property to AVI. The default is RGB.

Methods

cloneCreate multimedia file writer object with the same property values
closeRelease resources
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs of step method
isLockedLocked status for input attributes and nontunable properties
stepWrite one frame of audio output samples

Examples

Decimate an audio signal, and write signal to disk as an AVI file:

     hmfr = signalblks.MultimediaFileReader...
        ('AudioOutputDataType','double');
     hfirdec = dsp.FIRDecimator; % decimate by 2
     hmfw = signalblks.MultimediaFileWriter...
        ('speech_dft_11025.avi', ...
        'SampleRate', 22050/2);

     while ~isDone(hmfr)
          audio = step(hmfr);
          audiod = step(hfirdec, audio);
          step(hmfw, audiod);
     end

     close(hmfr);
     close(hmfw);

Algorithms

This object implements the algorithm, inputs, and outputs described on the To Multimedia File block reference page. The object properties correspond to the block parameters, except:

  • The Write block parameter corresponds to both the AudioOutputPort and the VideoOutputPort object properties.

  • The FrameRate and SampleRate properties are not available on the block. The block inherits these signals from the input line connected to the ports.

Was this topic helpful?