无法写入流数据,matlab

无法写入流数据,matlab,matlab,movie,bmp,Matlab,Movie,Bmp,我编写了一个脚本,将一组BMP转换为avi。直到最近,它还运作良好。现在我得到这个wierd错误“无法写入流数据”。我在将5个BMP库转换为avi后得到它。它运行在BMP库上,并将每个库转换为avi。每次它在第六部电影中叠加。。第六库中没有腐败文件。知道为什么吗 代码如下: %this works clc %path='C:/Documents and Settings/Ariel/Desktop/exp_brk_scrm/2.1/group1/exp_up/exp_up/4pyth

我编写了一个脚本,将一组BMP转换为avi。直到最近,它还运作良好。现在我得到这个wierd错误“无法写入流数据”。我在将5个BMP库转换为avi后得到它。它运行在BMP库上,并将每个库转换为avi。每次它在第六部电影中叠加。。第六库中没有腐败文件。知道为什么吗

代码如下:

%this works   
clc   
%path='C:/Documents and Settings/Ariel/Desktop/exp_brk_scrm/2.1/group1/exp_up/exp_up/4python/stims';   
%FullPath=strcat(path,'/mov1.avi');   
path4avi='G:/experiments/cfs3/building/Copy of StimBMP/avi/'; %dont forget the   in the end of the path    
pathOfFrames='G:/experiments/cfs3/building/Copy of StimBMP/stims/'; %here too   
NumberOfFiles=70; %to be generated   
NumberOfFrames=8; %in each avi file    

for i=1:1:(NumberOfFiles)    

    FileName=strcat(path4avi,'Stim',int2str(i),'.avi') %the generated files    
    aviobj = avifile(FileName,'compression','None'); %due to changes in the new Media Players   
    aviobj.fps=10;%10 frames in Sec     

    for j=1:1:(NumberOfFrames)   

        Frame=strcat(pathOfFrames,'stim',int2str(i),'/stim',int2str(j),'.BMP') % the BMP's (not a good name for thedirectory)    

        %[Fa,map]=imread(Frame);     
        %imshow(Fa,map); %
        [Fa,map]=imread(Frame);
        imshow(Fa,map);       
        % imshow(Fa);     
        F=getframe();    
        aviobj=addframe(aviobj,F)    
    end     
    aviobj=close(aviobj);    

end     

因为我不确定问题的根源是什么,所以我只提供一个简单的工作示例,说明如何创建AVI电影。使用图像处理工具箱中的演示图像:

figure('Color','white')
aviObj = avifile('out.avi', 'fps',5);             %# create AVI object
for i=1:10
    I = imread( sprintf('AT3_1m4_%02d.tif',i) );  %# read image frame
    imshow(I, 'Border','tight'), colormap gray    %# show image
    aviObj = addframe(aviObj, getframe(gcf));     %# grab frame and add to AVI
end
close(gcf)
aviObj = close(aviObj);                           %# close and write movie

winopen('out.avi')                                %# play movie in Windows

图书馆的顺序重要吗?换言之,如果你先跑第六个,后跑第一个,它会在第一个还是最后一个崩溃

如果它在第一个发生故障,那么您的库#6有问题
如果它在最后一天崩溃,您可能正在某处填充内存。在运行脚本之前,请使用
清除类
,这样可以消除Matlab在内存中填充的内容。或者,如果泄漏或碎片非常严重,您可以尝试在三个库之后重新启动Matlab。

您好,我知道这可能有点过于简化,但我也遇到了同样的问题。
我的代码运行得很好,只是有一天完全按照您所描述的那样停止了。我发现它只是我写文件的目的地,根本没有足够的内存来存储视频文件。删除了一些我不需要的垃圾,它立即生效。Matlab只是没有意识到存储空间的问题,所以在我的例子中,它说它自己的“movie2avi”功能有问题

是的。但除非您向我们展示一些代码,否则我们不会告诉您。我相信BMP文件不需要
map
。在imshow和imread中尝试了使用\不使用map的所有变体。。问题依然存在