VideoWriter create an empty video
2 次查看(过去 30 天)
显示 更早的评论
I have a problem with VideoWriter, after create the plot with the scatter function, Matlab create a new .avi file but it is empty, why?
figure ,hold on
xlim([25 31])
ylim([0 31])
c = colormap(jet(length(temp_discesa_i)));
for i = 1:length(temp_discesa_i)
pause(0.1)
scatter(temp_discesa_i(i), spazio_discesa_i(i),30,c(i,:),'filled');
pause(0.01);
end
video = VideoWriter('newfile2.avi', 'Uncompressed AVI');
open(video)
writeVideo(video,rand(300))
close(video)
Can someone help me? Thank you
Michela
1 个评论
Geoff Hayes
2017-7-4
Michela - what are you expecting to see in the video? When I run your code (or at least the last four lines), the newfile2.avi is created (roughly 335 kilobytes) with a single frame...since that is all that is being written to the video (a single 300x300 matrix). Are you expecting to see each frame of the updated plot? If so, then you have to create the video writer before your for loop and then, on each iteration of the loop, grab the frame from the plot and write it to file.
Please clarify what you are attempting to do.
回答(1 个)
Image Analyst
2017-7-4
You're only writing a single image to the video - it's all random numbers, plus it's floating point in the range 0-1 instead of the expected uint8 in the range 0-255.
To see how to do it, see the FAQ: http://matlab.wikia.com/wiki/FAQ#How_can_I_create_a_movie_from_my_MATLAB_figures.3F
Also, see my attached demos.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio and Video Data 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!