Main Content

To Multimedia File

Write video frames and audio samples to multimedia file

  • Library:
  • Computer Vision Toolbox / Sinks

  • To Multimedia File block

Description

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

You can compress the video frames or audio samples by selecting a compression algorithm. You can also control the type of video and/or audio in addition to other related properties 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.

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 (Simulink Coder) 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 Simulink Coder, Simulink Shared Library Dependencies, and Accelerating Simulink Models for details.

Ports

Input

expand all

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

Dependencies

To enable this port:

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

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

  • Set File color format parameter to RGB for AVI and MPEG4 file types.

  • Set Image signal parameter to One multidimensional signal.

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

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

Dependencies

To enable this port:

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

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

  • Set File color format parameter to RGB for AVI and MPEG4 file types.

  • Set Image signal parameter to Separate color signals.

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

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

Dependencies

To enable this port:

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

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

  • Set File color format parameter to RGB for AVI and MPEG4 file types.

  • Set Image signal parameter to Separate color signals.

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

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

Dependencies

To enable this port:

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

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

  • Set File color format parameter to RGB for AVI and MPEG4 file types.

  • Set Image signal parameter to Separate color signals.

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

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

Dependencies

To enable this port:

  • Set File type parameter to AVI or MPEG4.

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

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

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

Specify chrominance component, Cb, of input image as an M-by-N2 matrix.

Dependencies

To enable this port:

  • Set File type parameter to AVI or MPEG4.

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

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

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

Specify chrominance component, Cr, of input image as an M-by-N2 matrix.

Dependencies

To enable this port:

  • Set File type parameter to AVI or MPEG4.

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

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

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

Specify 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 File type parameter to AVI, WAV, WMA, MPEG4, FLAC or OGG.

  • Set Write parameter to Audio only.

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

Parameters

expand all

Specify the name of a multimedia file to write. The block appends the 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 existing file with the specified data.

The block saves the file in 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 AVI, WAV, MJ2000, WMA, WMV, MPEG4, FLAC, and OGG file formats.

Specify the type of media to write. You can select Video only, Audio only or Video and audio.

Dependencies

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

Specify the video compression algorithm to reduce the size of the output file.

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

  • MJ2000 file type — Select either 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 File type parameter to MJ2000, or AVI. For AVI file type, set Write parameter toVideo only or Video and audio.

Specify compression factor as an integer scalar greater than 1.

Dependencies

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

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

Dependencies

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

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

Dependencies

To enable this parameter, set 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 one port. If you select Separate color signals, the block accepts an input video using three separate ports for each color channel.

Dependencies

To enable this parameter:

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

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

  • Set File color format parameter to RGB for AVI and MPEG4 file types.

Specify the audio compression algorithm to reduce the size of the output file. The block supports CCITT A-Law, CCITT u-Law, GSM 3.10, IMA ADPCM, Microsoft ADPCM or 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 File type parameter to AVI and set Write parameter to Video and audio or Audio only.

  • Set File type parameter WAV

Specify the audio data type for the output file.

Dependencies

To enable this parameter select one of these options:

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

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

Block Characteristics

Data Types

double | integer[a] | 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

Introduced before R2006a