How to fast process conversion of .tif image sequence to an .avi video
Show older comments
I wrote a code to automatically convert a large sequence of .tif files to .avi videos across multiple folders. In general I have 110000 tif files per folder and 11 folders that go through the processing. The result is 5 videos per folder in which each video consist of 110000/5=22000 frames.
So far so good, however, for this to happen it takes almost 48 hours (2 DAYS) of matlab running continuously!
Any recommendation on how to make this faster? The tif file size is small about 200x200, I use for loops and imread to read the tif files and VideoWriter to convert it. Here is a sample of my code
for SubSession=1:number_of_frames/5:number_of_frames
%%Process File
MovieFrame_Order=1;
for FrameID=SubSession:SubSession+(number_of_frames/5)-1
fullFileName=fullfile(thisFolder,baseFileNames{FrameID}); %fullfile(thisFolder, baseFileNames(Trials));
AllOtherFrames = imread(strcat(fullFileName)); % load images from tif and convert to double
EBC_Frame_movie(:,:,MovieFrame_Order)=AllOtherFrames;
MovieFrame_Order=MovieFrame_Order+1;
end
%% Create Sub_Session video
newVid = VideoWriter([strcat(pwd,'/DATAfolder/',Title_movie,'.avi')]); % save new movie
newVid.FrameRate = 200;
newVid.Quality = 100;
open(newVid)
for t = 1:size(EBC_Frame_movie,3)
figure(1)
imshow(EBC_Frame_movie(:,:,t),'Border','tight');
axis off;
axis equal
EBC_movie_Output = getframe(figure(1));
writeVideo(newVid,EBC_movie_Output) % saving one frame at a time to make the movie
end
close(newVid)
Accepted Answer
More Answers (0)
Categories
Find more on Video Formats and Interfaces in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!