Main Content

To Multimedia File

Write video frames and audio samples to multimedia file

  • To Multimedia File block

Libraries:
Computer Vision Toolbox / Sinks

Description

The To Multimedia File block writes video frames, audio samples, or both to a multimedia file (.avi, .wav, .mj2, .mp4, or .m4v format).

You can compress the video frames or audio samples by selecting a compression algorithm. You can also control the type of video or audio in addition to other related properties the multimedia file receives.

If you have a Simulink® Coder™ license, you can generate a code from a model containing this block. To run a generated executable file, you may need to add precompiled shared library files to your system path. See Simulink Shared Library Dependencies, and Accelerating Simulink Models for details.

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.

Ports

Input

expand all

Specify the input image frame as a matrix or an array. To write an intensity image frame to a multimedia file, specify it as an M-by-N matrix. For a color image frame, specify it as an M-by-N-by-3 array.

Dependencies

To enable this port:

  • Set the File type parameter to AVI, MJ-2000, WMV, or MPEG4.

  • If the File type parameter value is not MJ-2000, set the Write parameter to Video and audio or Video only.

  • If the File type parameter value is AVI or MPEG4, set the File color format parameter to RGB.

  • Set the Image signal parameter to One multidimensional signal.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the red color component of the input image frame as an M-by-N matrix.

Dependencies

To enable this port:

  • Set the File type parameter to AVI, MJ-2000, WMV, or MPEG4.

  • If the File type parameter value is not MJ-2000, set the Write parameter to Video and audio or Video only.

  • If the File type parameter value is AVI or MPEG4, set the File color format parameter to RGB.

  • Set the Image signal parameter to Separate color signals.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the green color component of the input image frame as an M-by-N matrix.

Dependencies

To enable this port:

  • Set the File type parameter to AVI, MJ-2000, WMV, or MPEG4.

  • If the File type parameter value is not MJ-2000, set the Write parameter to Video and audio or Video only.

  • If the File type parameter value is AVI or MPEG4, set the File color format parameter to RGB.

  • Set the Image signal parameter to Separate color signals.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the blue color component of the input image frame as an M-by-N matrix.

Dependencies

To enable this port:

  • Set the File type parameter to AVI, MJ-2000, WMV, or MPEG4.

  • If the File type parameter value is not MJ-2000, set the Write parameter to Video and audio or Video only.

  • If the File type parameter value is AVI or MPEG4, set the File color format parameter to RGB.

  • Set the Image signal parameter to Separate color signals.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the luma component of the input image frame as an M-by-N matrix.

Dependencies

To enable this port:

  • Set the File type parameter to AVI or MPEG4.

  • Set the Write parameter to Video and audio or Video only.

  • Set the File color format parameter to YCbCr 4:2:2.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the blue-difference chrominance component of the input image as an M-by-N/2 matrix.

Dependencies

To enable this port:

  • Set the File type parameter to AVI or MPEG4.

  • Set the Write parameter to Video and audio or Video only.

  • Set the File color format parameter to YCbCr 4:2:2.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the red-difference chrominance component of the input image as an M-by-N/2 matrix.

Dependencies

To enable this port:

  • Set the File type parameter to AVI or MPEG4.

  • Set the Write parameter to Video and audio or Video only.

  • Set the File color format parameter to YCbCr 4:2:2.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean

Specify the input audio signal as a vector or a matrix. When specified as a matrix, the block treats each column as an independent channel.

Dependencies

To enable this port:

  • Set the File type parameter to AVI, WAV, WMA, MPEG4, FLAC, or OGG.

  • If the File type parameter value is AVI, WMV, or MPEG4 set the Write parameter to Video and audio or Audio only.

Data Types: single | double | int16 | int32 | uint8

Parameters

expand all

Specify the name for the multimedia file the block writes. The block appends a file extension automatically based on the specified File type parameter. If the specified file name, including the file extension, already exists, the block overwrites the data in the existing file with the new input data.

By default, the block saves the file in the current working directory. To specify a different file location, click the Save As... button.

Specify the type of multimedia file to write. The block supports the AVI, WAV, MJ2000, WMA, WMV, MPEG4, FLAC, and OGG file formats.

Specify the type of media to write. Depending on the value of the File type parameter, you can select Video only, Audio only, or Video and audio.

Type of fileSupported type of media
AVI
  • Video only

  • Audio only

  • Video and audio

WMV
  • Video only

  • Video and audio

MPEG4
  • Video only

  • Audio only

Dependencies

To enable this parameter, set the File type parameter to AVI, WMV, or MPEG4.

Specify a video compression algorithm to reduce the size of the output file. The available options depend on the value of the File type parameter.

  • AVI — Select either the DV Video Encoder or MJPEG Compressor algorithm. If you do not want to reduce the size of the file, select None (uncompressed).

  • MJ2000 — Select either the Lossy or Lossless algorithm.

Note

The options for this parameter are the video compression algorithms installed on your system. For information about a specific video compressor, see the documentation for that compressor.

Dependencies

To enable this parameter, set the File type parameter to MJ2000 or AVI. For the AVI file type, set the Write parameter to Video only or Video and audio.

Specify the compression factor as an integer greater than 1.

Dependencies

To enable this parameter, set the File type parameter to MJ2000 and the Video compressor parameter to Lossy.

Specify the quality of the video as an integer in the range [0, 100].

Dependencies

To enable this parameter, set the File type parameter to MPEG4 and the Write parameter to Video only.

Specify the color format of the video for the output file. The block supports the RGB and YCbCr 4:2:2 color formats.

Dependencies

To enable this parameter, set the File type parameter to AVI or MPEG4.

Specify how the block accepts an RGB color video input. If you select One multidimensional signal, the block accepts input using only the Image port. If you select Separate color signals, the block accepts an input video using three separate color channels, divided across the R, G, and B ports.

Dependencies

To enable this parameter:

  • Set the File type parameter to AVI, MJ-2000, WMV, or MPEG4.

  • Set the Write parameter to Video and audio or Video only.

  • If the File type parameter value is AVI or MPEG4, set the File color format parameter to RGB.

Specify an audio compression algorithm to reduce the size of the output file. The block supports the CCITT A-Law, CCITT u-Law, GSM 6.10, IMA ADPCM, Microsoft ADPCM, and PCM algorithms. If you do not want to reduce the size of the file, select None (uncompressed).

Note

The options for this parameter are the audio compression algorithms installed on your system. For information about a specific audio compressor, see the documentation for that compressor.

Dependencies

To enable this parameter, use either of these options:

  • Set the File type parameter to AVI and set the Write parameter to Video and audio or Audio only.

  • Set the File type parameter to WAV.

Specify the audio data type for the output file.

Dependencies

To enable this parameter select, use either of these options:

  • Set the File type parameter to WAV and the Audio compressor parameter to None (uncompressed).

  • Set the File type parameter to FLAC. This file type supports only the 8-bit integer, 16-bit integer, and 24-bit integer data types.

Block Characteristics

Data Types

double | integera | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

a Supports 16- and 32-bit signed and 8-bit unsigned integers.

Extended Capabilities

Version History

Introduced before R2006a