Main Content

From Multimedia File

Stream from multimedia file

  • From Multimedia File block

Libraries:
Audio Toolbox / Sources
DSP System Toolbox / Sources

Description

The From Multimedia File block reads audio samples, video frames, or both from a multimedia file and generates a signal with one of the following data types and amplitude ranges.

Output Data TypeOutput Amplitude Range

double

±1

single

±1

int16

−32768 to 32767 (−215 to 215 − 1)

uint8

0 to 255

The block imports data from the file into a Simulink® model.

Note

This block supports code generation for a host computer that has file I/O available. You cannot use this block with Simulink Desktop Real-Time™ software because that product does not support file I/O. The generated code for this block relies on prebuilt library files. For more details, see Code Generation.

Limitations

To support OPUS file format on a Linux® machine, you must have libsndfile 1.0.29 or a later version installed. On Windows® and Mac, this file is shipped with MATLAB® and is available under $MATLABROOT/bin/<platform>.

Ports

The output ports of the From Multimedia File block change according to the content of the multimedia file. If the file contains only video frames, the Image port, intensity I port, R,G,B ports, or Y,Cb,Cr ports appear based on the settings on the block dialog box. If the file contains only audio samples, the Audio port appears on the block. If the file contains both audio and video, you can select the data to emit. This section describes these ports in more detail.

Output

expand all

Color image or video frame, returned as an M-by-N-by-P array. M and N are the number of rows and columns in each image. P is the number of color channels in each image.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

  • Set the Output color format parameter to RGB and Image signal parameter to One multidimensional signal.

  • This port is named as Simulink Image if the Output color format parameter is set to RGB and the Image signal parameter is set to Simulink image signal.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Simulink.ImageType

Grayscale image or video frame, returned as an M-by-N matrix. M and N are the number of rows and columns in the grayscale image.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

  • Set the Output color format parameter to Intensity.

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

Red color component of the image or video frame, returned as an M-by-N matrix. M and N are the number of rows and columns in the image.

Outputs from the R, G, or B ports must have the same dimensions.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

  • Set the Output color format parameter to RGB and Image signal parameter to Separate color signals.

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

Green color component of the image or video frame, returned as an M-by-N matrix. M and N are the number of rows and columns in the image.

Outputs from the R, G, or B ports must have the same dimensions.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

  • Set the Output color format parameter to RGB and Image signal parameter to Separate color signals.

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

Blue color component of the image or video frame, returned as an M-by-N matrix. M and N are the number of rows and columns in the image.

Outputs from the R, G, or B ports must have the same dimensions.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

  • Set the Output color format parameter to RGB and Image signal parameter to Separate color signals.

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

Luma component of the image or video frame, returned as an M-by-N matrix. M and N are the number of rows and columns in the image.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

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

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

Blue-difference chrominance component of the image or video frame, returned as an M-by-N/2 matrix. M and N are the number of rows and columns in the input image.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

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

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

Red-difference chrominance component of the image or video frame, returned as an M-by-N/2 matrix. M and N are the number of rows and columns in each input image.

Dependencies

To enable this port:

  • Set the File name parameter to the name of a multimedia file that contains video or image data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

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

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

Audio signal, returned as an M-element vector or an M-by-N matrix. M is the number of samples in each channel and N is the number of channels.

Dependencies

To enable this port, set the File name parameter to the name of a multimedia file that contains audio data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Audio only or Video and audio.

Data Types: single | double | int16 | uint8

End-of-file indicator, returned as a logical scalar for each video frame or audio sample. The end-of-file indicator is 1 when the block outputs the final video frame or audio sample from the file, and is 0 otherwise.

Dependencies

To enable this port, select the Output end-of-file indicator parameter.

Data Types: Boolean

Parameters

expand all

Main Tab

Specify the name of the multimedia file for the block to read. The block determines the type of file (audio and video, audio only, or video only) and provides the associated parameters.

If the location of the file does not appear on the MATLAB path, use the Browse button to specify the full path. If the location of the file appears on the MATLAB path, enter only the file name.

On Windows platforms, this parameter supports URLs that point to MMS (Microsoft Media Server) streams.

Specify whether the block inherits the sample time from the multimedia file or uses a specified sample time. When you select this parameter, the block inherits the sample time from the input multimedia file. When you clear this parameter, the block uses the sample time that you specify in the Desired sample time parameter.

Tip

Select this parameter when you do not know the intended sample rate of the multimedia file.

Specify the block sample time.

Dependencies

To enable this parameter, clear the Inherit sample time from file parameter.

Specify the number of times to play the input multimedia file. The default value of inf specifies that the block repeats playing the multimedia file until the simulation stop time.

Specify the sample range from which to read as a two-element row vector in the form of [StartSample EndSample], where StartSample is the sample at which file reading starts, and EndSample is the sample at which file reading stops.

Dependencies

To enable this parameter, set the File name parameter to the name of a multimedia file that contains audio data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Audio only.

Use this parameter to determine whether the output is the last video frame or audio sample in the multimedia file. When you select this parameter, a Boolean output port labeled EOF appears on the block. The output from the EOF port defaults to 1 when the last video frame or audio sample is output from the block. Otherwise, the output from the EOF port defaults to 0.

Specify the type of media to read from a file containing both video and audio data.

Dependencies

To enable this parameter, set the File name parameter to the name of a multimedia file that contains both audio and video data.

Specify number of samples per audio channel. This parameter becomes available for files containing audio.

Dependencies

To enable this parameter, set the File name parameter to the name of a multimedia file that contains audio data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Audio only.

Specify the output color format of the input video data. The block supports the RGB, Intensity, and YCbCr 4:2:2 color formats.

If you select RGB, use the Image signal parameter to specify how to output a color signal.

Dependencies

To enable this parameter, set the File name parameter to the name of a multimedia file that contains video data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

Specify how the block outputs an RGB color video. If you select:

  • One multidimensional signal –– The block outputs an M-by-N-by-P color video signal through the Image port, where P is the number of color planes.

  • Separate color signals –– The block outputs the video data using three separate color channels, divided across the R, G, and B ports. Each port outputs one M-by-N plane of an RGB video stream.

  • Simulink image signal –– The block outputs a video in Simulink.ImageType datatype.

Dependencies

To enable this parameter:

  • Set the File name parameter to the name of a multimedia file that contains video data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

  • Set the Output color format parameter to RGB.

Data Types Tab

Specify the data type for the audio samples output at the Audio port.

Dependencies

To enable this parameter, set the File name parameter to the name of a multimedia file that contains audio data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Audio only or Video and audio.

Specify the data type of the video frames output at the R, G, B, or Image ports..

Dependencies

To enable this parameter, set the File name parameter to the name of a multimedia file that contains video data. If the specified file contains both audio and video data, set the Multimedia outputs parameter to Video only or Video and audio.

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.

More About

expand all

Extended Capabilities

Version History

Introduced before R2006a

expand all