Is there a way to speed up video writing in matlab?
48 views (last 30 days)
Show older comments
I'm having trouble with the performance of video writing. Each frame takes 0.7 seconds to write (considering only the writeVideo function). Is there a way to speed up this process?
v = VideoWriter('video.avi');
v.FrameRate = 4;
open(v)
set(gcf,'units','normalized','outerposition',[0 0 1 1])
for i = 1:100
imshow(I)
frame = getframe(figHand);
writeVideo(v,frame);
end
0 Comments
Answers (1)
Walter Roberson
on 18 Jan 2018
imshow() is slow. Avoid continually calling it.
v = VideoWriter('video.avi');
v.FrameRate = 4;
open(v)
set(gcf,'units','normalized','outerposition',[0 0 1 1])
for i = 1:100
if i == 1;
h = imshow(I);
else
set(h, 'CData', I);
end
frame = getframe(figHand);
writeVideo(v,frame);
end
2 Comments
Walter Roberson
on 19 Jan 2018
I wonder if it would be more efficient to batch the write calls? Gather several frames into a structure array and writeVideo that ?
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!