VideoWriter frame count problem

9 ビュー (過去 30 日間)
ksus
ksus 2018 年 7 月 3 日
回答済み: ksus 2018 年 7 月 3 日
Hi,
I am trying to create a movie from a bunch of PNG images (10 in number) that are stored in a folder. My code looks like this:
img_folder = 'Libraries\Documents\myImageFolder\';
img_format = '*.png';
images = dir(fullfile(img_folder,img_format));
for i = 1:10
img = imread(images(i).name);
imshow(imageFile);
v = VideoWriter('test.avi');
videoFile.FrameRate = 3;
open(v)
frames = getframe(gcf);
writeVideo(v,frame);
end
close(v);
when I run the code, the figures show up and are refershed as the loop runs. The code ends with everything seemingly fine without any error. But when I run the video file test.avi, I only see the last frame and the movie abruptly ends. When I check the value of frame count from the workspace, it says frame count = 1. It should be 10 as there are 10 images and the for loop loops over 10 images. What am I doing wrong.
Help much appreciated.

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 3 日
The call to VideoWriter should be before the loop.

その他の回答 (1 件)

ksus
ksus 2018 年 7 月 3 日
Great thanks. It works.

カテゴリ

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