如何解决如何在matlab中预分配VideoWriter文件
我的代码使用 VideoWriter
函数在 for 循环中生成 10 个视频。我知道如何预分配数组,但我不确定如何为 VideoWriter 文件进行预分配。应预先分配以下代码中的 writerObj 文件。
for i=1:10
images = cell(28,1);
writerObj(i) = VideoWriter(sprintf('bc_e2_ld_e5_time_history1/%d.avi',i));
writerObj(i).FrameRate = 1; % create the video writer with 1 fps
secsPerImage = ones(1,28); % set the seconds per image
open(writerObj(i)); % open the video writer
%-----------------------------Save images for making videos ---------------
for j=1:28
h=figure('visible','off');
p = pcolor(intrpVMStress1(:,:,j));
p.EdgeColor='none';
set(gca,'visible','off')
colormap('jet');
% colorbar;
axis equal;
title 'Von Mises Stress';
saveas(h,sprintf('bc_e2_ld_e5_time_history1/FIG%d.jpg',j)); % save the images
images{j}=imread(sprintf('bc_e2_ld_e5_time_history1/FIG%d.jpg',j)); % load the images
end
%-----------------------------convert the image to a frame ---------------
for u=1:length(images)
% convert the image to a frame
frame = im2frame(images{u});
for v=1:secsPerImage(u)
writeVideo(writerObj(i),frame);
end
end
close(writerObj(i));
end
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)