Appending image frames to existing avi file

조회 수: 21 (최근 30일)
JohnDylon
JohnDylon 2016년 8월 8일
답변: JohnDylon 2016년 8월 8일
Can anyone suggest how to append frames to an existing video file? I tried the code below in a for loop, however what I get is it can only create a new file only from given frames and doesn't append to the existing file.
outvid=VideoWriter([vidoutpath, name_vidout]);
outvid.FrameRate=mov.FrameRate;
open(outvid)
for pgc=1:length(RGBbin(1,1,1,:))
writeVideo(outvid, RGBbin(:,:,:,pgc));
end
close(outvid)
Thnx.

채택된 답변

JohnDylon
JohnDylon 2016년 8월 8일
I found a workaround. Since writeVideo can't append frames to a closed video file, (in my case) closing video in an appropriate step solves the problem. For example,
open(outvid);
for bin=1:n % An individual bin contains a number of frames say 1K
start=some calculation;
finish=some other calculation;
for frame=start:finish
writeVideo(outvid, framesource(frame));
end
% Video object is not closed here
end
close(outvid);
Thank for help.
JD

추가 답변 (1개)

Walter Roberson
Walter Roberson 2016년 8월 8일
VideoWriter cannot append frames.
You might be able to edit the C++ code given in http://www.mathworks.com/matlabcentral/fileexchange/280-aviwrite . Or possibly you could make use of the 'Continue' and 'Initialized' options of https://www.mathworks.com/matlabcentral/fileexchange/15881-mmwrite

카테고리

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