MATLAB movie2avi cannot made video

1 回表示 (過去 30 日間)
Kelvin
Kelvin 2015 年 10 月 28 日
回答済み: Kelvin 2015 年 10 月 30 日
I am trying to test the function movie2avi using simple codes in R2014a as follows:
clear; close all;
figure;
Z = peaks;
surf(Z);
axis tight manual;
ax = gca;
ax.NextPlot = 'replaceChildren';
loops = 40;
F(loops) = struct('cdata',[],'colormap',[]);
for j = 1:loops
X = sin(j*pi/10)*Z;
surf(X,Z);
drawnow;
F(j) = getframe(gcf);
end
movie(F);
movie2avi(F, 'myPeaks.avi', 'compression', 'None');
It seems the movie(F) works well but the avi file created contains the toolbar and background instead of just showing the graph. Also the avi file just show stationary picture as follow:
https://www.dropbox.com/s/otgnhc9ucfehqwk/a.png?dl=0
Another version of the program produce the same result: clc;clear; close all;
figure;
Z = peaks;
surf(Z);
axis tight manual;
ax = gca;
ax.NextPlot = 'replaceChildren';
v = VideoWriter('newfile2.avi','Uncompressed AVI');
open(v);
loops = 40;
F(loops) = struct('cdata',[],'colormap',[]);
for j = 1:loops
X = sin(j*pi/10)*Z;
surf(X,Z);
drawnow;
F = getframe(gcf);
writeVideo(v,F);
end
close(v);
There is also a warning:
Warning: Struct field assignment overwrites a value with class "double". See MATLAB R14SP2 Release Notes, Assigning Nonstructure Variables As Structures Displays Warning, for details.
Please help. Thanks.

採用された回答

Kelvin
Kelvin 2015 年 10 月 30 日
I added a command "set(gcf,'Renderer','zbuffer');" when I use R2014a and the problem is solved. It is just like using writeVideo in R2015a without that command. Thank you.

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2015 年 10 月 28 日
gcf is Get Current Figure. You are asking for the entire figure to be recorded, not just the plot, which would be gca
  3 件のコメント
Kelvin
Kelvin 2015 年 10 月 29 日
I also tried writeVideo as updated above but failed.
Kelvin
Kelvin 2015 年 10 月 30 日
Update: I added a command "set(gcf,'Renderer','zbuffer');" when I use R2014a and the problem is solved. It is just like using writeVideo in R2015a without that command. Thank you.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by