Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

To Multimedia File

Stream video frames and audio samples to multimedia file

Library

Sinks

dspsnks4

Description

The To Multimedia File block writes video frames, audio samples, or both to a multimedia (.avi, .wav, .wma, .mp4, .ogg, .flac, or .wmv) file.

You can compress the video frames or audio samples by selecting a compression algorithm. You can connect as many of the input ports as you want. Therefore, you can control the type of video and/or audio the multimedia file receives.

    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 block performs best on platforms with Version 11 or later of Windows Media® Player software. This block supports only uncompressed RGB24 AVI files on Linux® and Mac platforms.

    Windows® 7 UAC (User Account Control), may require administrative privileges to encode WMV and WMA files.

The generated code for this block 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 a model containing this block, you may need to add precompiled shared library files to your system path. See Understanding C Code Generation for details.

Cross-Platform Supported File Formats for Audio Files

Audio files can be of the following formats on all platforms:

  • WAV

  • FLAC

  • OGG

  • MPEG4 (only on Windows 7 and Mac OS X)

The default format is WAV. This block supports MPEG-4 AAC audio files on Windows 7, and Mac OS X. You can use both M4A and MP4 extensions. The following platform specific restrictions apply when writing these files:

Windows 7Mac OS X
  • Only sample rates of 44100 and 48000 Hz are supported.

  • Only mono or stereo outputs are allowed for MPEG-4 AAC file format. For all other formats, more than two audio output channels are allowed.

  • Only mono or stereo outputs are allowed for MPEG-4 AAC file format. For all other formats, more than two audio output channels are allowed.

  • The output data is padded on both the front and back of the signal, with extra samples of silence.

    Windows AAC encoder places sharp fade-in and fade-out on audio signal, causing signal to be slightly longer in samples when written to disk.

  • Not all sampling rates are supported, although the Mac Audio Toolbox API do not explicitly specify a restriction.

  • A minimum of 1025 samples per channel must be written to the MPEG-4 AAC file.

Ports

PortDescription

Image

M-by-N-by-3 matrix RGB, Intensity, or YCbCr 4:2:2 signal.

R, G, B

Matrix that represents one plane of the RGB video stream. Inputs to the R, G, or B port must have the same dimensions and data type.

Audio

M-by-N matrix. M is the number of samples in each channel, and N is the number of channels.

Y, Cb, Cr

Matrix that represents one frame of the YCbCr video stream. The Y, Cb, and Cr ports use the following dimensions:

Y: M x N
Cb: M xN2
Cr: M xN2

Dialog Box

The Main pane of the To Multimedia File block dialog appears as follows.

File name

Specify the name of the multimedia file. The block saves the file in your current folder. To specify a different file or location, click the Save As... button.

File type

Specify the file type of the multimedia file. You can select AVI, WAV, MJ2000, WMA, WMV, MPEG4, FLACC, or OGG. By default, the File type is set to WAV.

Write

Specify whether the block writes video frames, audio samples, or both to the multimedia file. You can select Video and audio, Video only, or Audio only. This parameter is visible only when you set File type to AVI, MPEG4, or OGG.

Audio compressor

Select the type of compression algorithm to use to compress the audio data. This compression reduces the size of the multimedia file. Choose None (uncompressed) to save uncompressed audio data to the multimedia file.

    Note:   The other items available in this parameter list are the audio compression algorithms installed on your system. For information about a specific audio compressor, see the documentation for that compressor.

Audio data type

Select the audio data type. You can use the Audio data type parameter only for uncompressed wave files.

Video compressor

Select the type of compression algorithm to use to compress the video data. This compression reduces the size of the multimedia file. Choose None (uncompressed) to save uncompressed video data to the multimedia file.

    Note:   The other items available in this parameter list are the video compression algorithms installed on your system. For information about a specific video compressor, see the documentation for that compressor.

Compression Factor (>1)

Specify the compression factor as an integer scalar greater than 1. This parameter is applicable only when the File type is set to MJ2000 and Video compressor is set to Lossy. By default, this parameter is set to 10.

File color format

Select the color format of the data stored in the file. You can select either RGB or YCbCr 4:2:2.

Image signal

Specify how the block accepts a color video signal. If you select One multidimensional signal, the block accepts an M-by-N-by-P color video signal, where P is the number of color planes, at one port. If you select Separate color signals, additional ports appear on the block. Each port accepts one M-by-N plane of an RGB video stream.

Video Quality (0-100)

Quality of the video specified as an integer scalar in the range [0 100]. This parameter is applicable only when File name is set to MPEG4 and Write is set to Video only. By default, this parameter is set to 75.

Troubleshooting

Running an Executable Outside MATLAB

To run your generated standalone executable application in Shell, you need to set your environment to the following:

PlatformCommand
Macsetenv DYLD_LIBRARY_PATH "${DYLD_LIBRARY_PATH}:$MATLABROOT/bin/maci64" (csh/tcsh)

export DYLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MATLABROOT/bin/maci64 (Bash)

Linuxsetenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:$MATLABROOT/bin/glnxa64 (csh/tcsh)

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$MATLABROOT/bin/glnxa64 (Bash)

Windows

set PATH=%PATH%;%MATLABROOT%\bin\win64

Supported Data Types

For the block to display video data properly, double- and single-precision floating-point pixel values must be between 0 and 1. Any other data type requires the pixel values between the minimum and maximum values supported by their data type.

Check the specific codecs you are using for supported audio rates.

PortSupported Data TypesSupports Complex Values?

Image

  • Double-precision floating point

  • Single-precision floating point

  • Boolean

  • 8-, 16- 32-bit signed integers

  • 8-, 16- 32-bit unsigned integers

No

R, G, B

Same as Image port

No

Audio

  • Double-precision floating point

  • Single-precision floating point

  • 16-bit signed integers

  • 32-bit signed integers

  • 8-bit unsigned integers

No

Y, Cb, Cr

Same as Image port

No

Introduced before R2006a

Was this topic helpful?