VideoWriter create an empty video

6 ビュー (過去 30 日間)
Michela Longhi
Michela Longhi 2017 年 7 月 4 日
回答済み: Image Analyst 2017 年 7 月 4 日
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
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
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.
Also, see my attached demos.

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by