write frames to a video

来源:互联网 发布:傲世奇侠传java 编辑:程序博客网 时间:2024/05/20 09:44
%# figurefigure, set(gcf, 'Color','white')Z = peaks; surf(Z);  axis tightset(gca, 'nextplot','replacechildren', 'Visible','off');[az,el]=view;xl=xlim;yl=ylim;zl=zlim;%# preallocatenFrames = 20;mov(1:nFrames) = struct('cdata',[], 'colormap',[]);%# create moviefor k=1:nFrames   view([(az-k*10) el]);   xlim(xl);ylim(yl);zlim(zl);   drawnow;pause(0.1);   mov(k) = getframe(gcf);endclose(gcf)%# save as AVI file, and open it using system video player%writeVideo(mov, 'myPeaks1.avi', 'compression','None', 'fps',10);v = VideoWriter('myPeaks1.avi','Uncompressed AVI');v.FrameRate = 10;open(v);writeVideo(v,mov)close(v);


要设置 video的一些属性请看https://uk.mathworks.com/help/matlab/ref/videowriter.html


Properties

expand all

ColorChannels — Number of color channelspositive integer

Colormap — Color information for video fileP-by-3 numeric matrix

CompressionRatio — Target compression ratio10 (default) | integer greater than 1

Duration — Duration of output filescalar value

FileFormat — Type of file to write'avi' | 'mp4' | 'mj2'

Filename — Name of filestring

FrameCount — Number of framesinteger

FrameRate — Rate of video playback30 (default) | positive number

Height — Height of each video framescalar

LosslessCompression — Lossless compressiontrue | false

MJ2BitDepth — Bit depth for Motion JPEG 2000 filesinteger in the range [1,16]

Path — Full path to video filestring

Quality — Video quality75 (default) | integer in the range [0,100]

VideoBitsPerPixel — Number of bits per pixelnumeric scalar

VideoCompressionMethod — Type of video compression'None' | 'H.264' | 'Motion JPEG' | 'Motion JPEG 2000'

VideoFormat — MATLAB representation of video formatstring

Width — Width of each video framenumeric scalar




0 0
原创粉丝点击