close all, clear; %inputVideoName = '50_20120117_12-12-30_LATE.asf'; inputVideoName = 'cam60_20120117_12-02-04_h264.asf'; outputSeqName = 'cam60.seq'; fps = 2; videoHandle = mmreader(inputVideoName); %Gets information on the video nFrames = get(videoHandle,'numberOfFrames'); info.width = get(videoHandle,'width'); info.height = get(videoHandle,'height'); info.quality = 100; info.codec = 'png'; info.fps = fps; %nFrames = 100; % TEST TEST TEST sw = seqIo(outputSeqName , 'writer', info ); %Open file for writing blockSize = 100; %Number of frames that are processed in one cycle (I don't load the whole video file at once, not to require a huge amount of memory) for (count=1:blockSize:nFrames-blockSize) videoBlock = read(videoHandle, [count count+blockSize]); %Get some frames, stores them as videoBlock(row, col, rgbLayer, imageNumber) -> value %I store a "time stamp" with every image, which coincides with the position of the image inside the stream for(count2 = 1:blockSize) sw.addframe(videoBlock(:,:,:,count2), ... count -1 + count2 -1); % I use this fake "time stamp", it seems that it is needed end end %Add the trainling frames that do not make a full block videoBlock = read(videoHandle, [count+blockSize nFrames]); for(count2 = count+blockSize:nFrames) sw.addframe(videoBlock(:,:,:,count2-count-blockSize +1), ... count2); %fake time stamp, see below end sw.close();