Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

VideoWriter

Create object to write video files

Syntax

  • v = VideoWriter(filename)
    example
  • v = VideoWriter(filename,profile)
    example

Description

example

v = VideoWriter(filename) creates a VideoWriter object to write video data to an AVI file with Motion JPEG compression.

example

v = VideoWriter(filename,profile) creates a VideoWriter object and applies a set of properties tailored to a specific file format (such as 'MPEG-4' or 'Uncompressed AVI').

Examples

collapse all

Create a VideoWriter object to write a Motion JPEG AVI file named newfile.avi.

v = VideoWriter('newfile.avi');

Open the file for writing and write a 300-by-300 matrix of data to the file.

open(v)
writeVideo(v,rand(300))

Close the file.

close(v)

Create an array containing data from the sample still image, peppers.png.

A = imread('peppers.png');

Create a VideoWriter object for a new uncompressed AVI file for RGB24 video.

v = VideoWriter('newfile.avi','Uncompressed AVI');

Open the file for writing.

open(v)

Write the image in A to the video file.

writeVideo(v,A)

Close the file.

close(v)

Input Arguments

collapse all

File name, specified as a character vector. VideoWriter creates the file.

VideoWriter supports these file extensions.

.avi

AVI file

.mj2

Motion JPEG 2000 file

.mp4 or .m4v

MPEG-4 file (systems with Windows® 7 or later, or Mac OS X 10.7 and later)

If you do not specify a valid file extension, VideoWriter appends the extension .avi, .mj2 or .mp4, depending on the value of the profile argument. If you do not specify a value for profile, then VideoWriter creates a Motion JPEG compressed AVI file with the extension .avi.

Example: 'myFile.avi'

Example: '../dir/videos/myFile.mj2'

Data Types: char

File type, specified as one of the following.

Value of profileDescription

'Archival'

Motion JPEG 2000 file with lossless compression

'Motion JPEG AVI'

AVI file using Motion JPEG encoding

'Motion JPEG 2000'

Motion JPEG 2000 file

'MPEG-4'

MPEG-4 file with H.264 encoding (systems with Windows 7 or later, or Mac OS X 10.7 and later)

'Uncompressed AVI'

Uncompressed AVI file with RGB24 video

'Indexed AVI'

Uncompressed AVI file with indexed video

'Grayscale AVI'

Uncompressed AVI file with grayscale video

profile sets default values for video properties such as VideoCompressionMethod.

Output Arguments

collapse all

Output VideoWriter object. After you create a VideoWriter object, you can write video files using object functions. See VideoWriter for details.

More About

Introduced in R2010b

Was this topic helpful?