Products & Services Solutions Academia Support User Community Company

Learn more about Signal Processing Blockset   

From Multimedia File - Read multimedia file

Library

Signal Processing Sources

dspsrcs4

Description

The From Multimedia File block reads audio and/or video frames from a multimedia file. The block imports data from the file into a Simulink model.

Reading video files requires the Video and Image Processing Blockset™ product.

Setting up the From Multimedia File Block

Use the File name parameter to specify the name of the multimedia file from which to read. If the location of the file does not appear on your MATLAB path, use the Browse button to specify the full path. Otherwise, if the location of this file appears on your MATLAB path, enter only the file name. On Windows® platforms, this parameter supports URLs that point to NMS (Microsoft Media Server) streams. For more information, see Supported File Types

Select the Inherit sample time from file check box if you want the block sample time to be the same as the multimedia file. If you clear this check box, enter the block sample time in the Desired sample time parameter field. The file that the From Multimedia File block references, determines the block default sample time. You can also set the sample time for this block manually. If you do not know the intended sample rate of the video, let the block inherit the sample rate from the multimedia file.

Port Behavior

The output ports of the From Multimedia File block change according to the content of the multimedia file. If the file contains video frames, the Image or intensity I port appears on the block. If the file contains audio only samples, the Audio port appears on the block. If the file contains both audio and video, you can select to output the audio. The following table describes the ports available.

PortDescription
Image

M-by-N-by-Pcolor video signal where P is the number of color planes.

I

M-by-N matrix of intensity values.

R, G, B

Matrix that represents one plane of the RGB video stream. Outputs from the R, G, or B port must have same dimensions.

Audio

Vector of audio data.

Accessing the Video or Audio

You can view the video frames using a To Video Display block and listen to the audio using a To Audio Device block.

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

Supported File Types

With the necessary codecs installed on your system, the From Multimedia File Block supports several video and audio file formats on various platforms.

This block performs best on platforms with Version 9.0 or later of DirectX® software. On the UNIX® product platforms, this block supports only uncompressed AVI files, less than 4 GB. Also, it does not support OpenDML extensions to the AVI standard.

Windows Platforms Supported File Formats


Multimedia TypesFile Name Extensions
Video files.qt, .mov, .avi, .asf, .asx, .wmv, .mpg, .mpeg, .mp2, .mp4
Audio files.wav, .wma, .aif, .aifc, .aiff, .mp3, .au, .snd

Non-Windows Platform Supported File Formats


Multimedia TypesFile Name Extensions
Video files.avi

Sample Rate Calculation

The sample rate depends on the audio and video sample rate. While the FMMF block operates at a single rate in Simulink, the underlying audio and video streams can produce different rates. In some cases, when the block outputs both audio and video, makes a small adjustment to the video rate.

The following table provides the Sample time calculations that the From Multimedia File block uses for video and audio files.

For Video FilesFor Audio FilesFor Video and Audio Files

Sample time =

where FPS is the Frames per Second.

Sample time =

where 1024 is the size of the audio frame, set by the block.

Sample time =

When audio sample time is is noninteger, the calculation does not equal . .

In this case, to prevent synchronization problems, the block drops the corresponding video frame when the audio stream leads the video stream by more than

The block outputs one video frame at each Simulink time step. To calculate the number of audio samples to output at each time step, the block divides the audio sample rate by the video frame rate (fps). If the audio sample rate does not divide evenly by the number of video frames per second, two operations occur:

Dialog Box

File name

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

Inherit sample time from file

Select this check box if you want the sample time of the block to equal the sample time of the multimedia file.

Desired sample time

Specify the block sample time. This parameter becomes available if you clear the Inherit sample time from file check box.

Number of times to play file

Enter a positive integer or inf to represent the number of times to play the file.

Output end-of-file indicator

Use this check box to determine whether the output is the last video frame or audio sample in the multimedia file. When you select this check box, 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.

Multimedia outputs

Specify Video and audio, Video only, or Audio only output file type. This parameter becomes available only when a video signal has both audio and video.

Image color space

Specify whether you want the block to output RGB or Intensity video frames. This parameter becomes available only for a signal that contains video. If you select RGB, use the Image signal parameter to specify how to output a color signal.

Image signal

Specify how to output a color video signal. If you select One multidimensional signal, the block outputs 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 outputs one M-by- N plane of an RGB video stream. This parameter becomes available only if you set the Image color space parameter to RGB and the signal contains video.

Samples per audio frame

Specify number of samples per audio frame. This parameter becomes available only for audio-only files.

Audio output data type

Set the data type of the audio samples output at the Audio port. This parameter becomes available only if the multimedia file contains audio. You can choose double, single, int16, or uint8 types.

Video output data type

Set the data type of the video frames output at the R, G, B, or Image ports. This parameter becomes available only if the multimedia file contains video. You can choose double, single, int8, uint8, int16, uint16, int32, uint32, or Inherit from file types.

Troubleshooting

If the From Multimedia File block cannot read some compressed multimedia files onWindows XP x64 platforms.

  1. Windows XP x64 ships with a limited set of 64-bit video and audio codecs.

    There are two known workarounds for this issue:

    1. Run the 32-bit version of MATLAB on your Windows XP x64 platform. Windows XP x64 ships with many 32-bit codecs.

    2. Change the multimedia file to a format using a codec supported on the Windows XP x64 platform.

Supported Data Types

PortSupported Data TypesSupports Complex Values?

Image

  • Double-precision floating point

  • Single-precision floating point

  • 8-, 16-, and 32-bit signed integers

  • 8-, 16-, and 32-bit unsigned integers

 

R, G, B

Same as the Image port

No

Audio

  • Double-precision floating point

  • Single-precision floating point

  • 16-bit signed integers

  • 8-bit unsigned integers

No

See Also

To Multimedia FileSignal Processing Blockset
From Wave FileSignal Processing Blockset
Image From WorkspaceVideo and Image Processing Blockset
To Video DisplayVideo and Image Processing Blockset
Video From WorkspaceVideo and Image Processing Blockset
Video ViewerVideo and Image Processing Blockset
Working with Sample TimesSimulink

  


Related Products & Applications

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS