Read, Process, and Write Video Frames to File
This example shows you how to read video frames from a multimedia file, process them, and write them back to a new multimedia file.
Example Model
Open the Simulink® model.
modelname = 'ex_blkMultiMediaFile.slx';
open_system(modelname)
The model reads an input video file using a 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 a Contrast Adjustment block with default settings. This block adjusts the contrast of the luminance (Y
) component of each frame of the video.
The model writes the processed video frames to a file using a To Multimedia File block with the File color format parameter set to YCbCr 4:2:2
. This block uses the default output file name of output.avi
.
Simulate Model
Run the model and confirm that the model writes the output file 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 this figure. The top image shows one frame of the input video file, with default contrast, and the bottom image shows the corresponding frame of the output video file, with adjusted contrast.
sim(modelname);