Appending image frames to existing avi file

11 次查看(过去 30 天)
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

Community Treasure Hunt

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

Start Hunting!

Translated by