From Multimedia File - Read video frames and/or audio samples from multimedia file

Library

Signal Processing Sources

dspsrcs4

Description

The From Multimedia File block reads video frames and/or audio samples from a multimedia file and imports them into a Simulink model. Video processing requires the Video and Image Processing Blockset™ product.

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

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 port appears on the block. If the file contains audio samples, the Audio port appears on the block.

PortOutputSupported Data TypesSupports Complex Values?

Image

M-by-N matrix of intensity values or an M-by-N-by-P color video signal where P is the number of color planes

  • 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

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

Same as the Image port

No

Audio

Vector of audio data

  • Double-precision floating point

  • Single-precision floating point

  • 16-bit signed integers

  • 8-bit unsigned integers

No

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.

Use the File name parameter to specify the name of the multimedia file from which to read. If the location of this file is on your MATLAB path, enter the filename. If the location of this file is not on your MATLAB path, use the Browse button to specify the full path to the file as well as the filename. On Windows platforms, this parameter supports URLs that point to multimedia files. For more information, see Supported File Formats – Windows Platforms.

Select the Inherit sample time from file check box if you want the sample time of the block to be the same as the sample time of the multimedia file. If you clear this check box, use the Desired sample time parameter to specify the block's sample time.

The default sample time for the From Multimedia File block is determined by the file that it references. You can also set the sample time for this block manually. Unless you already know the video's intended sample rate, set the sample rate from the file. If you have other sources in your model which need to operate at the same rate, you can set them to inherit the sample rate.

The table below 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 non-integer, the calculation does not equal . In this case, to prevent synchronization problems, the corresponding video frame is dropped when the audio stream leads the video stream by more than .

Use the Number of times to play file parameter to enter the number of times to play the file. The number you enter must be a positive integer or inf.

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

Use the Image color space parameter to specify whether you want the block to output RGB or intensity video frames. If you select RGB, use the Image signal parameter to specify how to output a color 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.

Use the Audio output data type parameter to set the data type of the audio samples output at the Audio port. You can choose double, single, int16, or uint8.

Use the Video output data type parameter to set the data type of the video frames output at the R, G, B, or Image ports. You can choose double, single, int8, uint8, int16, uint16, int32, uint32, or Inherit from file.

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). In the event that the audio sample rate is not evenly divisible by the number of video frames per second, two things occur:

Troubleshooting

There are two issues that you need to be aware of when using the From Multimedia File block.

  1. On Windows XP x64 platforms, the From Multimedia File block might not be able to read some compressed multimedia files because Windows XP x64 ships with a limited set of 64-bit video and audio codecs.

    There are two known workarounds:

    1. Run the 32-bit version of MATLAB on your Windows XP x64 platform. Windows XP x64 ships with many 32-bit codecs that might work with your compressed multimedia file.

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

  2. When working with the From Multimedia File block, you might encounter this error: "ClassFactory cannot supply requested class". The From Multimedia File block uses the Microsoft® DirectX® product infrastructure, which does not allow you to play some AVI files from a remote network location.

    To workaround this issue, copy your AVI file to a local hard disk before using it with the From Multimedia File block.

Dialog Box

File name

Specify the name of the multimedia file from which to read. The block determines the type of file, for example audio and video, or audio 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 be the same as the sample time of the multimedia file.

Desired sample time

Specify the block's sample time. This parameter is 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.

Multimedia outputs

Specify Video and audio, Video only, or Audio only output file type. This parameter is 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 is available for a signal which contains video.

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 is only available if you set the Image color space parameter to RGB, and the signal contains video.

Audio output data type

Set the data type of the audio samples output at the Audio port. This parameter is only available if the multimedia file contains audio.

Video output data type

Set the data type of the video data output from the block. This parameter is only available if the multimedia file contains video.

Supported File Formats – Windows Platforms

This block can support the following file formats provided you have the necessary codecs installed on your system.

FormatFilename Extensions

Apple® QuickTime, Macintosh® AIFF Resource

.qt, .aif, .aifc, .aiff, .mov

Microsoft® Windows Media formats

.avi, .asf, .asx, .rmi, .wav, .wma, .wax, .wmv

Moving Picture Experts Group (MPEG)

.mpg, .mpeg, .mlv, .mp2, .mp3, .mpa, .mpe

Audio formats

.au, .snd

Supported File Formats – UNIX Platforms

FormatFilename Extensions

Microsoft Windows Media formats (uncompressed)

.avi

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

  


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