Filter löschen
Filter löschen

VideoWriter create an empty video

8 Ansichten (letzte 30 Tage)
Michela Longhi
Michela Longhi am 4 Jul. 2017
Beantwortet: Image Analyst am 4 Jul. 2017
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 Kommentar
Geoff Hayes
Geoff Hayes am 4 Jul. 2017
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.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Image Analyst
Image Analyst am 4 Jul. 2017
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.

Community Treasure Hunt

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

Start Hunting!

Translated by