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