在MATLAB电影文件创建问题 [英] Problems with movie file creation in MATLAB

查看:175
本文介绍了在MATLAB电影文件创建问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过帧MATLAB循环创造了电影。

I attempt to create a movie by looping through frames in MATLAB.

在为参照<一到mathworks.com文档href=\"http://www.mathworks.com/help/techdoc/ref/movie.html\">http://www.mathworks.com/help/techdoc/ref/movie.html,我已经成功的动画情节。然而,当我试图挽救电影AVI文件出现问题。

Refering to mathworks.com documentation at http://www.mathworks.com/help/techdoc/ref/movie.html, I've managed to animate a plot. However, issues arise when I attempt to save the movie in an avi file.

无论是从的 AVIFILE 和 VideoWriter 方法http://stackoverflow.com/a /8038540/818608\">http://stackoverflow.com/a/8038540/818608 ,导致同样的错误。

Both the avifile and VideoWriter methods from http://stackoverflow.com/a/8038540/818608, resulted in the same errors.

虽然动画运行正常,已保存的电影只由一个固定的框架,并在时间,屏幕捕捉,包括我的背景的网页浏览器的覆盖。

Although the animation runs fine, the saved movie consists of only one fixed frame, and at times, the screen capture includes an overlay of my background web browser.

感谢您提前。

下面是code我用,而这对AVI冻结帧下面链接。

Below is the code I used, and the frame that's frozen on the avi is linked below.

Z = peaks; surf(Z); 
axis tight
set(gca,'nextplot','replacechildren');

vid = VideoWriter('myPeaks2.avi');
vid.Quality = 100;
vid.FrameRate = 15;
open(vid);
for k = 1:20 
    surf(sin(2*pi*k/20)*Z,Z)
    writeVideo(vid, getframe(gcf));
end
close(vid);

winopen('myPeaks2.avi')

推荐答案

请尝试以下操作:

    f = figure();
    Z = peaks; surf(Z);
    a = axes('Parent',f);
    axis(a,'tight');
    set(a,'nextplot','replacechildren');
    vid = VideoWriter('myPeaks2.avi');
    vid.Quality = 100;
    vid.FrameRate = 15;
    open(vid);
    for k = 1:20
        surf(a,sin(2*pi*k/20)*Z,Z)
        writeVideo(vid, getframe(f));
    end
    close(vid);

    winopen('myPeaks2.avi')

它包含使用,而不是隐显手柄。许多乱在Matlab,因为人们倾向于使用隐式的,如它应该已经从语言彻底删除GCF,GCA,恕我直言引起的。

It contains explicit handles using instead of implicit. Many chaos is caused in Matlab because people tend to use the implicit ones, like "gcf", "gca" which should have been removed completely from the language, IMHO.

这篇关于在MATLAB电影文件创建问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆