In this example, you use the From Multimedia File blocks to import video and audio streams into a Simulink® model. You then write the audio and video to a single file using the To Multimedia File block.
You can open the example model by typing at the MATLAB® command line.
Run your model. The model creates a
multimedia file called
output.avi in your current
Play the multimedia file using a media player. The original video file now has an audio component to it.
The From Multimedia File block imports a video file into the model. During import, the Inherit sample time from file check box is deselected, which enables the Desired sample time parameter. The other default parameters are accepted.
The From Multimedia File block used for the input video file
inherits its sample time from the
For video signals, the sample time equals the frame period. The frame
period is defined as 1/(frame rate). Because the input video frame
rate is 30 frames per second (fps), the block sets the frame period
The From Multimedia File1 block imports an audio file into the model.
The Samples per audio channel parameter
is set to
735. This output audio frame size is
calculated by dividing the frequency of the audio signal (22050 samples
per second) by the frame rate (approximately 30 frames per second).
You must adjust the audio signal frame period to match the frame
period of the video signal. The video frame period is
per frame. Because the frame period is also defined as the frame size
divided by frequency, you can calculate the frame period of the audio
signal by dividing the frame size of the audio signal (735 samples
per frame) by the frequency (22050 samples per second) to get
|frame period = (frame size)/(frequency)|
|frame period = (|
|frame period = |
The To Multimedia File block is used to output
the audio and video signals to a single multimedia file. The
and audio option is selected for the Write parameter
One multidimensional signal for the Image
signal parameter. The other default parameters are accepted.
You can locate the Configuration Parameters by selecting Model Configuration Parameters from the Simulation menu. The parameters, on the Solver pane, are set as follows:
Stop time =
(no continuous states)