Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
bug with MATLAB example avifile

Subject: bug with MATLAB example avifile

From: didi mimi

Date: 26 Jan, 2010 16:18:02

Message: 1 of 9

hi
I tried to run the code from the matlab help in the section of avifile.

t = linspace(0,2.5*pi,40);
fact = 10*sin(t);
fig=figure;
aviobj = avifile('example.avi')
[x,y,z] = peaks;
for k=1:length(fact)
    h = surf(x,y,fact(k)*z);
    axis([-3 3 -3 3 -80 80])
    axis off
    caxis([-90 90])
    F = getframe(fig);
    aviobj = addframe(aviobj,F);
end
close(fig)
aviobj = close(aviobj);

It is indeed open an avi file, but I can't run it using windows media player (and the player works on other avi files that were created with flash)

is it a bug in the help's example or am I am doing something wrong

thanlks

Subject: bug with MATLAB example avifile

From: Leslie McBrayer

Date: 26 Jan, 2010 16:38:42

Message: 2 of 9

> I tried to run the code from the matlab help in the section of avifile.
>
> t = linspace(0,2.5*pi,40);
> fact = 10*sin(t);
> fig=figure;
> aviobj = avifile('example.avi')
> [x,y,z] = peaks;
> for k=1:length(fact)
> h = surf(x,y,fact(k)*z);
> axis([-3 3 -3 3 -80 80])
> axis off
> caxis([-90 90])
> F = getframe(fig);
> aviobj = addframe(aviobj,F);
> end
> close(fig)
> aviobj = close(aviobj);
>
> It is indeed open an avi file, but I can't run it using windows media
> player (and the player works on other avi files that were created with
> flash)
>
> is it a bug in the help's example or am I am doing something wrong

By default on Windows systems, avifile creates a compressed AVI file using
the Indeo 5 codec -- but this codec is no longer shipped on many systems.
Try creating an uncompressed AVI file:

aviobj = avifile('example.avi','compression','None');

Subject: bug with MATLAB example avifile

From: didi mimi

Date: 26 Jan, 2010 19:19:04

Message: 3 of 9

thank you, now it works fine.

Subject: bug with MATLAB example avifile

From: Michael Giacomelli

Date: 26 Jan, 2010 21:01:21

Message: 4 of 9

"didi mimi" <ariel_gold@walla.com> wrote in message <hjnf78$fv2$1@fred.mathworks.com>...
> thank you, now it works fine.

The matlab examples and documentation for AVI file are badly out of date. They don't even work on Win64 bit matlab due to default codec not running on 64 Windows. I filed a bug report with mathworks, so hopefully they'll correct it in 2010a.

Subject: bug with MATLAB example avifile

From: Davis

Date: 9 Feb, 2010 07:30:25

Message: 5 of 9

"didi mimi" <ariel_gold@walla.com> wrote in message <hjn4jq$hg6$1@fred.mathworks.com>...
> hi
> I tried to run the code from the matlab help in the section of avifile.
>
> t = linspace(0,2.5*pi,40);
> fact = 10*sin(t);
> fig=figure;
> aviobj = avifile('example.avi')
> [x,y,z] = peaks;
> for k=1:length(fact)
> h = surf(x,y,fact(k)*z);
> axis([-3 3 -3 3 -80 80])
> axis off
> caxis([-90 90])
> F = getframe(fig);
> aviobj = addframe(aviobj,F);
> end
> close(fig)
> aviobj = close(aviobj);
>
> It is indeed open an avi file, but I can't run it using windows media player (and the player works on other avi files that were created with flash)
>
> is it a bug in the help's example or am I am doing something wrong
>
> thanlks

I'm having a similar problem. Everything worked fine under 2007a in Vista32 but when I upgraded to 2009b it broke. It doesn't appear to be a problem with the compressor, since saving in uncompressed format didn't fix it. Only the first frame gets saved and the rest of the frames in the clip are the same as the first. Further, the frame that gets captured is semitransparent, so that the underlying windows show through. It appears to be problem with perhaps both getframe() and addframe().

Subject: bug with MATLAB example avifile

From: Els

Date: 7 Mar, 2010 19:25:09

Message: 6 of 9

I am having the same problem with the combination of addframe and getframe. Only the first frame shows. Does anyone have suggestions how to tackle this problem?

Maybe to use other commando's instead?

Subject: bug with MATLAB example avifile

From: adel

Date: 21 Apr, 2010 15:17:04

Message: 7 of 9

"Leslie McBrayer" <lmcbrayer@mathworks.com> wrote in message <hjn5qj$8ru$1@fred.mathworks.com>...
> > I tried to run the code from the matlab help in the section of avifile.
> >
> > t = linspace(0,2.5*pi,40);
> > fact = 10*sin(t);
> > fig=figure;
> > aviobj = avifile('example.avi')
> > [x,y,z] = peaks;
> > for k=1:length(fact)
> > h = surf(x,y,fact(k)*z);
> > axis([-3 3 -3 3 -80 80])
> > axis off
> > caxis([-90 90])
> > F = getframe(fig);
> > aviobj = addframe(aviobj,F);
> > end
> > close(fig)
> > aviobj = close(aviobj);
> >
> > It is indeed open an avi file, but I can't run it using windows media
> > player (and the player works on other avi files that were created with
> > flash)
> >
> > is it a bug in the help's example or am I am doing something wrong
>
> By default on Windows systems, avifile creates a compressed AVI file using
> the Indeo 5 codec -- but this codec is no longer shipped on many systems.
> Try creating an uncompressed AVI file:
>
> aviobj = avifile('example.avi','compression','None');
>
Try with this:
frame = getframe(gcf);
aviobj = addframe(aviobj,frame);

HTH

Subject: bug with MATLAB example avifile

From: Leng-Feng Lee

Date: 3 Jun, 2010 21:35:05

Message: 8 of 9

I have the same problem. Using the example given in avifile, added compression to none, the resulting avi only capture the first frame, with some transparency added.
------------------------------------------------------------
       t = linspace(0,2.5*pi,40);
       fact = 10*sin(t);
       fig=figure;
       aviobj = avifile('example.avi','compression','none')
       [x,y,z] = peaks;
       for k=1:length(fact)
           h = surf(x,y,fact(k)*z);
           axis([-3 3 -3 3 -80 80])
           axis off
           caxis([-90 90])
           F = getframe(fig);
           aviobj = addframe(aviobj,F);
       end
       close(fig)
       aviobj = close(aviobj);
------------------------------------------------------------
I am using win7 64bits and MATLAB 2009b.

Because of the transparency, I tried turn off the Win7 window transparency setting, but no luck.

Lee

 

Subject: bug with MATLAB example avifile

From: Andreas Ferber

Date: 26 Jul, 2010 12:21:04

Message: 9 of 9

Hi all I have the same problem with the example file.

aviobj = avifile('example.avi','compression','None');

t = linspace(0,2.5*pi,40);
fact = 10*sin(t);
fig=figure;
[x,y,z] = peaks;
for k=1:length(fact)
    h = surf(x,y,fact(k)*z);
    axis([-3 3 -3 3 -80 80])
    axis off
    caxis([-90 90])

    F = getframe(fig);
    aviobj = addframe(aviobj,F);
end
close(fig);
aviobj = close(aviobj);


But I know that it worked correctly some days ago. Could it be that I changed some default settings in matlab??
I use Windows 7 64bit and matlab R2010a
My avi file displays only the first frame, transparent.

Thanks for help

Andreas

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us