필터 지우기
필터 지우기

VideoWriter create an empty video

조회 수: 8 (최근 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 CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by