Main Content

Read, Process, and Write Video Frames

This example shows how to read video frames from a multimedia file, process it, and write it back to a multimedia file.

Example Model

Open the Simulink model®.

modelname = 'ex_blkMultiMediaFile.slx';

The model reads an input video file using the From Multimedia File block with these parameters:

  • File name : rhinos.avi

  • Output color format : YCbCr 4:2:2

To adjust the contrast of the input video, the model uses the Contrast Adjustment block with default settings. This block adjusts the contrast of luminance (Y) component of each frame of the video.

The model writes the processed video frames using To Multimedia File block with File color format parameter set to YCbCr 4:2:2. This block uses the default output file name as output.avi.

Simulate the Model

Run the model and notice that the output file is saved to the working directory. Play the output video and verify the change in contrast from the input video to the output video as shown in the figure below. The top image shows one frame of the input video file and the bottom image shows the corresponding frame of the output video file.