How to solve two axes in failure VideoWriter?
2 次查看(过去 30 天)
显示 更早的评论
for example, my code framework as follows:
- t=0:.1:2*pi;
- plot(t,sin(t),'k');
- axes('position',[0.55,0.55,0.3,0.3]);
- plot(t,sin(t), 'b');
there is two axes in one figure.
so when i use VideoWriter to export file.avi,the video is broken.
i think the proble maybe because of the axes(when i comment "axes('position',[0.55,0.55,0.3,0.3]);",all success!)
my question is how to export mp4/avi videos when the frame has two axes like the kind of above code?
2 个评论
Ganesh Regoti
2020-1-31
Hi Can you share the exact code? I don't think the issue is with axes. I have tried with another example and it worked.
Refer to the following link,
https://www.mathworks.com/matlabcentral/answers/384848-get-figures-and-use-them-to-build-a-video-avi
Here is the code with tweak
for i = 1:10
figure(1)
% imshow(processo(:,:,1,i))
hold on
plot(0+i,0+i,'o')
plot(1+i,i+i,'o')
plot(2+i,2+i,'o')
axes('position',[0.55,0.55,0.3,0.3]);
plot(3+i,3+i,'o')
plot(4+i,4+i,'o')
hold off
F(i) = getframe(gcf) ;
drawnow
end
% create the video writer with 1 fps
writerObj = VideoWriter('myVideo.avi');
writerObj.FrameRate = 10;
% set the seconds per image
% open the video writer
open(writerObj);
% write the frames to the video
for i=1:length(F)
% convert the image to a frame
frame = F(i) ;
writeVideo(writerObj, frame);
end
% close the writer object
close(writerObj);
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!