Skip to Main Content Skip to Search
Product Documentation

Exporting to Audio and Video

Exporting to Audio Files

In MATLAB, audio data is simply numeric data that you can export using standard MATLAB data export functions, such as save.

MATLAB also includes functions that write audio data to files in specific file formats:

Exporting Video to AVI Files

To create an Audio/Video Interleaved (AVI) file from MATLAB graphics animations or from still images, follow these steps:

  1. Create a VideoWriter object by calling the VideoWriter function. For example:

    myVideo = VideoWriter('myfile.avi');

    By default, VideoWriter prepares to create an AVI file using Motion JPEG compression. To create an uncompressed file, specify the Uncompressed AVI profile, as follows:

    myVideo = VideoWriter('myfile.avi', 'Uncompressed AVI');
  2. Optionally, adjust the frame rate (number of frames to display per second) or the quality setting (a percentage from 0 through 100). For example:

    myVideo.FrameRate = 15;  % Default 30
    myVideo.Quality = 50;    % Default 75

      Note   Quality settings only apply to compressed files. Higher quality settings result in higher video quality, but also increase the file size. Lower quality settings decrease the file size and video quality.

  3. Open the file:

    open(myVideo);

      Note   After you call open, you cannot change the frame rate or quality settings.

  4. Write frames, still images, or an existing MATLAB movie to the file by calling writeVideo. For example, suppose that you have created a MATLAB movie called myMovie. Write your movie to a file:

    writeVideo(myVideo, myMovie);

    Alternatively, writeVideo accepts single frames or arrays of still images as the second input argument. For more information, see the writeVideo reference page.

  5. Close the file:

    close(myVideo);

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

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