使用VideoWriter时出错

时间:2014-06-09 19:50:38

标签: matlab video

我正在使用MATLAB中的avi从一堆帧中创建一个VideoWriter文件。但是我收到了这个错误:

??? Error using ==> VideoWriter.VideoWriter>VideoWriter.writeVideo at 339
The 'cdata' field of FRAME must not be empty

由于我可以从同一个脚本创建jpg个文件,因此我知道会弹出一个图像。

这是我的代码:

%% Graph one site at a time
    writerObj = VideoWriter(['US_O3_MDA8_EUS_' num2str(years(y)) '_10-90.avi']);
    writerObj.FrameRate = 1;
    open(writerObj);

% Map of conterminous US
nFrames = length(date); % Number of frames.
for k = 1:nFrames % Number of days
    ax = figure(1);
    ax = usamap({'TX','ME'});
    latlim = getm(ax, 'MapLatLimit');
    lonlim = getm(ax, 'MapLonLimit');
    states = shaperead('usastatehi',...
        'UseGeoCoords', true, 'BoundingBox', [lonlim', latlim']);
    geoshow(ax, states, 'FaceColor', 'none')
    % framem off; gridm off; mlabel off; plabel off

    hold on

    % Plot data
    h = scatterm(ax,str2double(Lat_O3{k}), str2double(Lon_O3{k}), 40, str2double(data_O3{k})*1000, 'filled'); 

    % Set colorbar and title info

    % Capture the frame
    frame = getframe;
    writeVideo(writerObj,frame);

    clf
end
    % Save as AVI file 
    close(writerObj);
    close(gcf)

0 个答案:

没有答案