problem with videoWriter not closing

조회 수: 1 (최근 30일)
Teshan Rezel
Teshan Rezel 2022년 3월 14일
댓글: Teshan Rezel 2022년 3월 25일
Hi folks,
I am creating a video and having trouble with the videoWriter not closing, or taking a very long time to close.
May I please ask how to fix this? The code is as follows:
writerObj = VideoWriter(mainVideoName);
writerObj.FrameRate = 10;
open(writerObj);
for j = 1 : numMainImages
mainImg = imread([imageMainFolder imageMainFiles(j).name]);
mainImg = mainImg(:,:,1:3);
cropImg = imread([cropsFolder cropFiles(j).name]);
threshImg = im2uint8(imread([threshFolder threshFiles(j).name]));
h = figure;
h(1) = subplot(2, 2, 1);
image(cropImg, "Parent", h(1));
h(2) = subplot(2, 2, 2);
image(threshImg, "Parent", h(2));
h(3) = subplot(2, 2, 3:4);
image(mainImg, "Parent", h(3));
myText = ['Temperature = ', num2str(myTemp(j)), '^{o}C'];
annotation('textbox', [0.4, 0.55, 0,0], 'string', myText, "FitBoxToText","on");
h(2).Colormap = gray(256);
for k = 1:3
h(k).XAxis.Visible = "off";
h(k).YAxis.Visible = 'off';
end
thisFrame = getframe(gca);
writeVideo(writerObj, thisFrame);
end
close(writerObj);
  댓글 수: 5
Jan
Jan 2022년 3월 24일
@Teshan Rezel: Do not remove this question. Simply ask your new question and insert a link to this thread to avoid confusions. You can add a linl to the new question here also. Then everything is fine.
Teshan Rezel
Teshan Rezel 2022년 3월 25일
hi @Image Analyst, thanks for the response! It appears it doesn't actually get to the close(writeObj) statement as I left the programme running over 2 days and had no video files written.
I'm not sure why this is!

댓글을 달려면 로그인하십시오.

채택된 답변

yanqi liu
yanqi liu 2022년 3월 15일
yes,sir,may be use image replace frame to test,such as
writerObj = VideoWriter(mainVideoName);
writerObj.FrameRate = 10;
open(writerObj);
for j = 1 : numMainImages
mainImg = imread([imageMainFolder imageMainFiles(j).name]);
mainImg = mainImg(:,:,1:3);
cropImg = imread([cropsFolder cropFiles(j).name]);
threshImg = im2uint8(imread([threshFolder threshFiles(j).name]));
h = figure;
h(1) = subplot(2, 2, 1);
image(cropImg, "Parent", h(1));
h(2) = subplot(2, 2, 2);
image(threshImg, "Parent", h(2));
h(3) = subplot(2, 2, 3:4);
image(mainImg, "Parent", h(3));
myText = ['Temperature = ', num2str(myTemp(j)), '^{o}C'];
annotation('textbox', [0.4, 0.55, 0,0], 'string', myText, "FitBoxToText","on");
h(2).Colormap = gray(256);
for k = 1:3
h(k).XAxis.Visible = "off";
h(k).YAxis.Visible = 'off';
end
thisFrame = frame2im(getframe(gca));
writeVideo(writerObj, thisFrame);
end
close(writerObj);
  댓글 수: 2
Teshan Rezel
Teshan Rezel 2022년 3월 17일
@yanqi liu hi, thank you for this but it doesn't seem to solve the issue just yet!
Rik
Rik 2022년 3월 23일
I haven't read the rest of the thread, but can you explain what is different between what you need and what this suggestion does? Yanqi might be able to help you if you make it clear what should be different.
In general users with sufficient reputation points to delete posts, are not fans of doing that for legitimate content.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Language Support에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by