|
"amira ali" wrote in message <j5tmls$ohe$1@newscl01ah.mathworks.com>...
> hello
> i want to compree avi video file instead of using 25 frame/sec i want to use only 4 frame/sec how to samples this frames randomely my code but it doesn't work:
>
>
>
>
>
> vid='a.avi';
>
> aviobj = avifile(vid,'fps',4,'compression','Cinepak');
> vidObj = mmreader(vid);
> vidFrames = read(readerobj);
> numFrames = get(readerobj, 'numberOfFrames');
> vid_name= get(readerobj, 'name');
>
> for k = 1 : numFrames
> fig=figure;
> mov(k).cdata = vidFrames(:,:,:,k);
> mov(k).colormap = [];
>
> F = getframe(fig);
> aviobj = addframe(aviobj,F);
> end
> aviobj = close(aviobj);
i found the solution
fpath='C:\Program Files\MATLAB\R2011a\work\video_images\images\test\';
imglist=dir(fullfile(fpath,'*.jpeg'));
%imglist= dir([fpath '*.jpg']); % edit path/filename to match your images' location
% default-parameters:
fps= 10; % frames per second
fname='C:\Program Files\MATLAB\R2011a\work\video_images\images\test\h'; % path/name of movie output file
codec= 'hfyu'; % video codec (FOURCC), I use HuffYUV ('hfyu') because it is lossless
% create movie:
for k= 1:length(imglist);
img= imread([fpath imglist(k).name]); % get current frame
m(k)= im2frame(img);
if rem(k, 100) == 0
disp([num2str(k) ' frames processed...'])
% drawnow
end
end
% create avi:
movie2avi(m, fname, 'compression', 'Cinepak', 'fps', fps,'quality',10);
%movie2avi(m, fname, 'fps', fps);
disp('Playing movie file...');
%implay([fpath 'h.avi']);
|