Import from Video Files

In this example, you use the From Multimedia File source block to import a video stream into a Simulink® model and the To Video Display sink block to view it. This procedure assumes you are working on a Windows platform.

You can open the example model by typing

ex_import_mmfex_import_mmf

at the MATLAB® command line.

  1. Run your model.

  2. View your video in the To Video Display window that automatically appears when you start your simulation.

      Note:   The video that is displayed in the To Video Display window runs at the frame rate that corresponds to the input sample time. To run the video as fast as Simulink processes the video frames, use the Video Viewer block.

You have now imported and displayed a multimedia file in the Simulink model. In the Export to Video Files example you can manipulate your video stream and export it to a multimedia file.

For more information on the blocks used in this example, see the From Multimedia File and To Video Display block reference pages.

Setting Block Parameters for this Example

The block parameters in this example were modified from default values as follows:

BlockParameter
From Multimedia File

Use the From Multimedia File block to import the multimedia file into the model:

  • If you do not have your own multimedia file, use the default vipmen.avi file, for the File name parameter.

  • If the multimedia file is on your MATLAB path, enter the filename for the File name parameter.

  • If the file is not on your MATLAB path, use the Browse button to locate the multimedia file.

  • Set the Image signal parameter to Separate color signals.

By default, the Number of times to play file parameter is set to inf. The model continues to play the file until the simulation stops.

To Video Display

Use the To Video Display block to view the multimedia file.

  • Image signal: Separate color signals

Set this parameter from the Settings menu of the display viewer.

Configuration Parameters

You can locate the Model Configuration Parameters by selecting Model Configuration Parameters from the Simulation menu. For this example, the parameters on the Solver pane, are set as follows:

  • Stop time = 20

  • Type = Fixed-step

  • Solver = Discrete (no continuous states)

Was this topic helpful?