Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can read an AVI file into MATLAB <a href="http://www.mathworks.com/access/helpdesk/help/techdoc/import_export/f5-132080.html#f5-146610" rel="nofollow noreferrer">using the built-in <code>mmreader</code> class</a>. Once you have the AVI frames read into a structure array of movie frames, you can save them as a YUV file using the <code>saveFileYuv</code> function found in this submission from the <a href="http://www.mathworks.com/matlabcentral/fileexchange/" rel="nofollow noreferrer">MathWorks File Exchange</a>:</p> <ul> <li><a href="http://www.mathworks.com/matlabcentral/fileexchange/6318-convert-yuv-cif-420-video-file-to-image-files" rel="nofollow noreferrer">Convert YUV CIF 4:2:0 video file to image files</a> by <a href="http://www.mathworks.com/matlabcentral/fileexchange/authors/16240" rel="nofollow noreferrer">Da Yu</a></li> </ul> <p>Your code might look something like this:</p> <pre><code>%# Get the video data: vidObj = mmreader('myVideo.avi'); %# Create a video file object nFrames = vidObj.NumberOfFrames; %# Get the number of frames vidHeight = vidObj.Height; %# Get the image height vidWidth = vidObj.Width; %# Get the image width %# Preallocate the structure array of movie frames: mov(1:nFrames) = struct('cdata',zeros(vidHeight,vidWidth,3,'uint8'),... 'colormap',[]); %# Note that colormap is empty! %# Read each video frame into the structure array: for k = 1:nFrames mov(k).cdata = read(vidObj,k); %# Place frame k in the cdata field of mov(k) end %# Save the movie frame array as a YUV 4:2:0 file: saveFileYuv(mov,'myVideo.yuv',1); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload