Cannot using movie2avi in MATLAB
古いコメントを表示
I am trying to use the movie2avi function in MATLAB. I simply copy the sample program in my MATLAB R2015a:
nFrames = 20;
% Preallocate movie structure.
mov(1:nFrames) = struct('cdata', [],...
'colormap', []);
% Create movie.
Z = peaks; surf(Z);
axis tight manual
set(gca,'nextplot','replacechildren');
for k = 1:nFrames
surf(sin(2*pi*k/20)*Z,Z)
mov(k) = getframe(gcf);
end
% Create AVI file.
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
But an error message appears:
Error using avi
Unexpected Error. Reason: Failed to open file.
Error in audiovideo.internal.aviwriter (line 168)
aviobj.FileHandle = avi('open',filename);
Error in movie2avi (line 63)
avimov = audiovideo.internal.aviwriter(filename,varargin{:});
Error in MakeMovie (line 36)
movie2avi(mov, 'myPeaks.avi', 'compression', 'None');
What's wrong here? Please help.
回答 (1 件)
Dinesh Iyer
2015 年 10 月 16 日
0 投票
Can you check if the location you are attempting to write the file to has write permissions?
movie2avi is being deprecated. I would recommend using VideoWriter as it allows you the use of more modern compression methods such as MPEG-4, MJ200), MJPEG AVI.
Hope this helps.
Dinesh
5 件のコメント
Walter Roberson
2015 年 10 月 16 日
In particular check the directory that you are in when you try to execute the code. If you are on MS Windows Vista or later (I think it is) then if you are inside the directory that MATLAB was installed in, then you will not be able to write files there.
Kelvin
2015 年 10 月 17 日
Walter Roberson
2015 年 10 月 17 日
Try the command
fileattrib .
where the period ('.') is part of the command. That should tell you about the permissions of the current directory.
Kelvin
2015 年 10 月 20 日
編集済み: Walter Roberson
2015 年 10 月 20 日
Walter Roberson
2015 年 10 月 20 日
I do not know for sure, but I suggest trying again in a directory that does not have a space in its name.
カテゴリ
ヘルプ センター および File Exchange で File Operations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!