필터 지우기
필터 지우기

Matlab locks avi movie.

조회 수: 1 (최근 30일)
David Pesetsky
David Pesetsky 2016년 7월 12일
댓글: David Pesetsky 2016년 7월 12일
I am just executing the following example to create a avi movie. After it's done, I cannot rename the file because Windows claims Matlab still has it "open".
Z = peaks;
surf(Z)
axis tight manual
ax = gca;
ax.NextPlot = 'replaceChildren';
loops = 40;
F(loops) = struct('cdata',[],'colormap',[]);
for j = 1:loops
X = sin(j*pi/10)*Z;
surf(X,Z)
drawnow
F(j) = getframe(gcf);
end
fig = figure;
movie(fig,F,2);
movie2avi(F, 'awesomeMovie', 'compression', 'None');
What's a good way to break that connection?
Thank you. Dave

채택된 답변

Adam
Adam 2016년 7월 12일
Are you using a pre 2010b version of Matlab?
If not then you should be able to use VideoWriter instead as movie2avi will be removed in a future release (according to the help).
e.g.
v = VideoWriter('newfile.avi');
% set properties of VideoWriter
open(v)
writeVideo(v,rand(300))
close(v)
This includes a clear instruction to close the VideoWriter.
I guess in your case just doing an
fclose( 'awesomeMovie' )
ought to work.
  댓글 수: 6
David Pesetsky
David Pesetsky 2016년 7월 12일
Not sure movie2avi returns a pointer to an open file...
David Pesetsky
David Pesetsky 2016년 7월 12일
Ah! Guillaume, I just used VideoWriter to write a compact mp4 directly, rather than an avi and then compress it. Perfect. Thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by