2010-08-12 86 views
0

我寫了一個腳本,將一組BMP轉換爲AVI。直到最近它工作正常。現在我得到這個奇怪的錯誤「無法寫入流數據」。我將5個bmp文件庫轉換爲avi後得到它。它運行在BMP的圖書館管理員並將每個圖書館轉換爲AVI。每次它在第6部電影中堆疊..第6部電影庫中沒有損壞的文件。任何想法爲什麼?無法寫入流數據,matlab

這是代碼:

%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  
+0

是的。但除非您向我們展示一些代碼,否則我們不會告訴您。 – relet 2010-08-12 20:05:35

+0

我相信你不需要'映射'BMP文件。 – yuk 2010-08-12 20:39:22

+0

在imshow和imread中試圖用\沒有地圖的所有變化..問題依然存在 – ariel 2010-08-12 20:56:20

回答

1

因爲我不知道你的問題的根源是什麼,我只是提供瞭如何創建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 

out.avi

0

是否庫的順序有關係嗎?換句話說,如果你第一次和第一次跑第六次,它會在第一次還是最後一次崩潰?

如果它第一次崩潰,那麼你的圖書館#6有問題 如果它最後崩潰,你可能會填滿內存somehwere。在運行腳本之前使用clear classes,這應該消除內存中填充的任何Matlab。或者,如果泄漏或碎片非常糟糕,可以嘗試在三個庫之後重新啓動Matlab。

1

嗨,我知道這可能看起來有點過於簡化,但我有同樣的問題。 我的代碼工作正常,只有一天完全停止,正如你所描述的。我發現這只是我寫文件的目的地,沒有足夠的視頻文件存儲空間。刪除了一些我不需要的垃圾,並立即生效。 Matlab只是不知道存儲空間的問題,所以在我的情況下,它說它有自己的'movie2avi'函數的問題