Generate a movie silently
이전 댓글 표시
Dear all,
I am familiar with the standard procedure to create an animation/video in MATLAB with e.g.:
vidObj = VideoWriter('video.avi');
vidObj.FrameRate = 20;
vidObj.Quality = 100;
open(vidObj);
figure(Figure_Video)
currFrame=getframe(gcf);
writeVideo(vidObj,currFrame);
close(vidObj);
However, suppose if the creation of the animation takes few hours (one frame each minute) and i want to do some other work (writing texts, emails) with the same computer. Each minute MATLAB captures the display/mouse and makes it even unpossible to do some other work.
Therefore my question:
Is there an easy way to create an animation silently in the background?
Thank you!
댓글 수: 6
Image Analyst
2020년 5월 24일
Are you just creating images? Or are you doing graphics, like with plot(), line(), scatter(), etc.? If it's just images, there is no need to display them before adding to your movie structure.
ConvexHull
2020년 5월 24일
편집: ConvexHull
2020년 5월 24일
Image Analyst
2020년 5월 24일
편집: Image Analyst
2020년 5월 24일
There is a command line way to start MATLAB with a -nodisplay option though I've never done it. Put a line in your startup code to automatically launch your m-file and see if that works.
ConvexHull
2020년 5월 24일
Ameer Hamza
2020년 5월 24일
Which command are you using which grab the mouse attention from other applications? Using the code in your question does not result in grabbing the mouse attention. For example, run the following code. You can continue to work on your other applications (at least this works in macOS)
v = VideoWriter('temp.mp4', 'MPEG-4');
open(v)
x = linspace(1,10);
y = sin(x);
fig = figure();
for i=1:numel(x)
plot(x(1:i), y(1:i));
currFrame = getframe(fig);
writeVideo(v, currFrame);
end
close(v);
Although you can avoid multiple calls to plot(), I just write it like this to show even this does not grab attention. You are probably writing so another command which grabs attention. My guess is that you have written the line
figure(Figure_Video)
inside the loop.
Image Analyst
2020년 5월 24일
Also, switching to a particular axes will steal focus:
axes(handles.axesImage); % This call steals focus.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Animation에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!