MatLab,如何为电影预分配帧? [英] MatLab, how to preallocate for frames to make a movie?

查看:111
本文介绍了MatLab,如何为电影预分配帧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Matlab具有以下制作AVI格式电影的指南.我的目标是能够通过Powerpoint播放演示文稿中的视频.

Matlab has the following guide to making a movie in avi format. My goal is to be able to play the video in my presentation through powerpoint.

nFrames = 20;
% Preallocate movie structure.
mov(1:nFrames) = struct('cdata', [],...
                    'colormap', []);

% Create movie.
Z = peaks; surf(Z); 
axis tight
set(gca,'nextplot','replacechildren');
for k = 1:nFrames 
surf(sin(2*pi*k/20)*Z,Z)
mov(k) = getframe(gcf);
end

% Create AVI file.
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');

我理解此示例,并且我应该没有压缩才能加载到PowerPoint中.但是我不明白如何使用struct正确地预分配我的内存.

I understand this example and that I should have no compression to load into PowerPoint. However I dont understand how to properly preallocate my memory using struct.

推荐答案

您不需要预先分配.只需初始化mov = [].另外,getframe假定为gcf,因此您可以只使用mov(k) = getframe().我同意您想要未压缩的视频. Matlab随附的编解码器非常有限.如果空间很重要,则可以使用开源工具压缩视频.

You don't need to pre-allocate. Just initialize mov = []. Also getframe assumes gcf, so you can just use mov(k) = getframe(). I agree that you want an uncompressed video. The codecs that come with Matlab are pretty limited. You could use an open source tool to compress the video if space is important.

这篇关于MatLab,如何为电影预分配帧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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