|
"Travis " <traviib.nospam.@yahoo.com> wrote in message
<fb4lmd$cno$1@fred.mathworks.com>...
> Is there a way to create an MPEG movie frame by frame,
such
> as within a loop, similar to the addframe command used to
> create AVIs?
>
> I have tried using mpgwrite, but the arrays I am dealing
> with are too large to store at once and are currently
added
> to an avi frame by frame.... such as (within a loop):
>
> F = getframe(gca);
> aviobj = addframe(aviobj, F);
>
> I also tried using movieeditor to load the created AVI and
> convert it to an MPEG, but when using 150 mb avi's, the
> memory quickly balloons to 2 gigs and I therefore receive
an
> out of memory error.
>
> Any ideas? Thanks all.
Travis,
This is some stock movie demo code I trot out when someone
asks about this and I think it might be helpful as .avi is
very inefficient:
% Movie Demo
% create some image data
[X Y Z] = sphere(25);
sz = size(Z);
C = rand(sz(1),sz(2),3);
% stitch data to wrap color around sphere
C(:,end,:) = C(:,1,:);
% render an image
figure('color',[0 0 0]);
sp = surf(X,Y,Z,C,'FaceColor','interp',...
'FaceLighting','phong');
material shiny
axis off vis3d
cl = camlight('right');
camzoom(1.5)
set(sp,'edgecolor','none');
drawnow
% setup the rotation vector for the movie
view_vect_yaw = [-180:3:180];
sz_vect = size(view_vect_yaw);
% "lights, camera, action!"
for f = 1:sz_vect(2)
% set the view, reset light position and render
view([view_vect_yaw(f) 15]);
camlight(cl,'right')
drawnow
% grab a frame
m(f) = getframe(gcf);
end
% format frames as mpeg and write to file
mpgwrite(m,C,'my_movie.mpg',...
[1, 0, 1, 0, 10, 1, 1, 1]);
% end of code
This demo requires mpgwrite.dll which is available in the
file exchange. You just drop a copy of the dll into the
directory where you are developing and running your movie
code.
hth,
Scott
|