You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Cretae a video from Images using WriterObj
3 views (last 30 days)
Show older comments
I have 200 images, each one is an instantaneous frame captured each 0.1 sec. Therefore, I would like to create a video of 20 sec using all 200 frames. Anyone can help? Thanks and Regards.
Accepted Answer
Dinesh Iyer
on 6 Sep 2018
Edited: Dinesh Iyer
on 6 Sep 2018
Please see doc page for VideoWriter.
2 Comments
Davide Di Pasquale
on 6 Sep 2018
I have already had a look at it and I generated the following codes:
close all; clear all; clc; tic; myFolder = 'C:\Users\Desktop\Test'; if ~isdir(myFolder) errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder); uiwait(warndlg(errorMessage)); return; end
% load the images images = cell(200,1); images{1} = imread('vector1.png'); images{2} = imread('vector2.png'); images{3} = imread('vector3.png'); images{4} = imread('vector4.png'); images{5} = imread('vector5.png'); images{6} = imread('vector6.png'); images{7} = imread('vector7.png'); images{8} = imread('vector8.png'); images{9} = imread('vector9.png'); images{10} = imread('vector10.png'); images{11} = imread('vector11.png'); images{12} = imread('vector12.png'); images{13} = imread('vector13.png'); images{14} = imread('vector14.png'); images{15} = imread('vector15.png'); images{16} = imread('vector16.png'); images{17} = imread('vector17.png'); images{18} = imread('vector18.png'); images{19} = imread('vector19.png'); images{20} = imread('vector20.png'); images{21} = imread('vector21.png'); images{22} = imread('vector22.png'); images{23} = imread('vector23.png'); images{24} = imread('vector24.png'); images{25} = imread('vector25.png'); images{26} = imread('vector26.png'); images{27} = imread('vector27.png'); images{28} = imread('vector28.png'); images{29} = imread('vector29.png'); images{30} = imread('vector30.png'); images{31} = imread('vector31.png'); images{32} = imread('vector32.png'); images{33} = imread('vector33.png'); images{34} = imread('vector34.png'); images{35} = imread('vector35.png'); images{36} = imread('vector36.png'); images{37} = imread('vector37.png'); images{38} = imread('vector38.png'); images{39} = imread('vector39.png'); images{40} = imread('vector40.png'); images{41} = imread('vector41.png'); images{42} = imread('vector42.png'); images{43} = imread('vector43.png'); images{44} = imread('vector44.png'); images{45} = imread('vector45.png'); images{46} = imread('vector46.png'); images{47} = imread('vector47.png'); images{48} = imread('vector48.png'); images{49} = imread('vector49.png'); images{50} = imread('vector50.png'); images{51} = imread('vector51.png'); images{52} = imread('vector52.png'); images{53} = imread('vector53.png'); images{54} = imread('vector54.png'); images{55} = imread('vector55.png'); images{56} = imread('vector56.png'); images{57} = imread('vector57.png'); images{58} = imread('vector58.png'); images{59} = imread('vector59.png'); images{60} = imread('vector60.png'); images{61} = imread('vector61.png'); images{62} = imread('vector62.png'); images{63} = imread('vector63.png'); images{64} = imread('vector64.png'); images{65} = imread('vector65.png'); images{66} = imread('vector66.png'); images{67} = imread('vector67.png'); images{68} = imread('vector68.png'); images{69} = imread('vector69.png'); images{70} = imread('vector70.png'); images{71} = imread('vector71.png'); images{72} = imread('vector72.png'); images{73} = imread('vector73.png'); images{74} = imread('vector74.png'); images{75} = imread('vector75.png'); images{76} = imread('vector76.png'); images{77} = imread('vector77.png'); images{78} = imread('vector78.png'); images{79} = imread('vector79.png'); images{80} = imread('vector80.png'); images{81} = imread('vector81.png'); images{82} = imread('vector82.png'); images{83} = imread('vector83.png'); images{84} = imread('vector84.png'); images{85} = imread('vector85.png'); images{86} = imread('vector86.png'); images{87} = imread('vector87.png'); images{88} = imread('vector88.png'); images{89} = imread('vector89.png'); images{90} = imread('vector90.png'); images{91} = imread('vector91.png'); images{92} = imread('vector92.png'); images{93} = imread('vector93.png'); images{94} = imread('vector94.png'); images{95} = imread('vector95.png'); images{96} = imread('vector96.png'); images{97} = imread('vector97.png'); images{98} = imread('vector98.png'); images{99} = imread('vector99.png'); images{100} = imread('vector100.png'); images{101} = imread('vector101.png'); images{102} = imread('vector102.png'); images{103} = imread('vector103.png'); images{104} = imread('vector104.png'); images{105} = imread('vector105.png'); images{106} = imread('vector106.png'); images{107} = imread('vector107.png'); images{108} = imread('vector108.png'); images{109} = imread('vector109.png'); images{110} = imread('vector110.png'); images{111} = imread('vector111.png'); images{112} = imread('vector112.png'); images{113} = imread('vector113.png'); images{114} = imread('vector114.png'); images{115} = imread('vector115.png'); images{116} = imread('vector116.png'); images{117} = imread('vector117.png'); images{118} = imread('vector118.png'); images{119} = imread('vector119.png'); images{120} = imread('vector120.png'); images{121} = imread('vector121.png'); images{122} = imread('vector122.png'); images{123} = imread('vector123.png'); images{124} = imread('vector124.png'); images{125} = imread('vector125.png'); images{126} = imread('vector126.png'); images{127} = imread('vector127.png'); images{128} = imread('vector128.png'); images{129} = imread('vector129.png'); images{130} = imread('vector130.png'); images{131} = imread('vector131.png'); images{132} = imread('vector132.png'); images{133} = imread('vector133.png'); images{134} = imread('vector134.png'); images{135} = imread('vector135.png'); images{136} = imread('vector136.png'); images{137} = imread('vector137.png'); images{138} = imread('vector138.png'); images{139} = imread('vector139.png'); images{140} = imread('vector140.png'); images{141} = imread('vector141.png'); images{142} = imread('vector142.png'); images{143} = imread('vector143.png'); images{144} = imread('vector144.png'); images{145} = imread('vector145.png'); images{146} = imread('vector146.png'); images{147} = imread('vector147.png'); images{148} = imread('vector148.png'); images{149} = imread('vector149.png'); images{150} = imread('vector150.png'); images{151} = imread('vector151.png'); images{152} = imread('vector152.png'); images{153} = imread('vector153.png'); images{154} = imread('vector154.png'); images{155} = imread('vector155.png'); images{156} = imread('vector156.png'); images{157} = imread('vector157.png'); images{158} = imread('vector158.png'); images{159} = imread('vector159.png'); images{160} = imread('vector160.png'); images{161} = imread('vector161.png'); images{162} = imread('vector162.png'); images{163} = imread('vector163.png'); images{164} = imread('vector164.png'); images{165} = imread('vector165.png'); images{166} = imread('vector166.png'); images{167} = imread('vector167.png'); images{168} = imread('vector168.png'); images{169} = imread('vector169.png'); images{170} = imread('vector170.png'); images{171} = imread('vector171.png'); images{172} = imread('vector172.png'); images{173} = imread('vector173.png'); images{174} = imread('vector174.png'); images{175} = imread('vector175.png'); images{176} = imread('vector176.png'); images{177} = imread('vector177.png'); images{178} = imread('vector178.png'); images{179} = imread('vector179.png'); images{180} = imread('vector180.png'); images{181} = imread('vector181.png'); images{182} = imread('vector182.png'); images{183} = imread('vector183.png'); images{184} = imread('vector184.png'); images{185} = imread('vector185.png'); images{186} = imread('vector186.png'); images{187} = imread('vector187.png'); images{188} = imread('vector188.png'); images{189} = imread('vector189.png'); images{190} = imread('vector190.png'); images{191} = imread('vector191.png'); images{192} = imread('vector192.png'); images{193} = imread('vector193.png'); images{194} = imread('vector194.png'); images{195} = imread('vector195.png'); images{196} = imread('vector196.png'); images{197} = imread('vector197.png'); images{198} = imread('vector198.png'); images{199} = imread('vector199.png'); images{200} = imread('vector200.png'); % create the video writer with 1 fps writerObj = VideoWriter('200fr_10new.avi'); writerObj.FrameRate = 1; writerObj.Quality = 100; % set the seconds per image secsPerImage=[0.1:0.1:20.0]; % open the video writer open(writerObj); % write the frames to the video for u=1:length(images) % convert the image to a frame frame = im2frame(images{u}); for v=1:secsPerImage(u) writeVideo(writerObj, frame); end end % close the writer object close(writerObj); fprintf('Video done in %.1f s. Enjoy! \n\n', toc) % diary off;
but It does not work.
Davide Di Pasquale
on 6 Sep 2018
if true
close all; clear all; clc; tic;
myFolder = 'C:\Users\Desktop\Test';
if ~isdir(myFolder)
errorMessage = sprintf('Error: The following folder does not exist:\n%s', myFolder);
uiwait(warndlg(errorMessage));
return;
end
% load the images images = cell(200,1); images{1} = imread('vector1.png'); images{2} = imread('vector2.png'); images{3} = imread('vector3.png'); images{4} = imread('vector4.png'); images{5} = imread('vector5.png'); images{6} = imread('vector6.png'); images{7} = imread('vector7.png'); images{8} = imread('vector8.png'); images{9} = imread('vector9.png'); images{10} = imread('vector10.png'); images{11} = imread('vector11.png'); images{12} = imread('vector12.png'); images{13} = imread('vector13.png'); images{14} = imread('vector14.png'); images{15} = imread('vector15.png'); images{16} = imread('vector16.png'); images{17} = imread('vector17.png'); images{18} = imread('vector18.png'); images{19} = imread('vector19.png'); images{20} = imread('vector20.png'); images{21} = imread('vector21.png'); images{22} = imread('vector22.png'); images{23} = imread('vector23.png'); images{24} = imread('vector24.png'); images{25} = imread('vector25.png'); images{26} = imread('vector26.png'); images{27} = imread('vector27.png'); images{28} = imread('vector28.png'); images{29} = imread('vector29.png'); images{30} = imread('vector30.png'); images{31} = imread('vector31.png'); images{32} = imread('vector32.png'); images{33} = imread('vector33.png'); images{34} = imread('vector34.png'); images{35} = imread('vector35.png'); images{36} = imread('vector36.png'); images{37} = imread('vector37.png'); images{38} = imread('vector38.png'); images{39} = imread('vector39.png'); images{40} = imread('vector40.png'); images{41} = imread('vector41.png'); images{42} = imread('vector42.png'); images{43} = imread('vector43.png'); images{44} = imread('vector44.png'); images{45} = imread('vector45.png'); images{46} = imread('vector46.png'); images{47} = imread('vector47.png'); images{48} = imread('vector48.png'); images{49} = imread('vector49.png'); images{50} = imread('vector50.png'); images{51} = imread('vector51.png'); images{52} = imread('vector52.png'); images{53} = imread('vector53.png'); images{54} = imread('vector54.png'); images{55} = imread('vector55.png'); images{56} = imread('vector56.png'); images{57} = imread('vector57.png'); images{58} = imread('vector58.png'); images{59} = imread('vector59.png'); images{60} = imread('vector60.png'); images{61} = imread('vector61.png'); images{62} = imread('vector62.png'); images{63} = imread('vector63.png'); images{64} = imread('vector64.png'); images{65} = imread('vector65.png'); images{66} = imread('vector66.png'); images{67} = imread('vector67.png'); images{68} = imread('vector68.png'); images{69} = imread('vector69.png'); images{70} = imread('vector70.png'); images{71} = imread('vector71.png'); images{72} = imread('vector72.png'); images{73} = imread('vector73.png'); images{74} = imread('vector74.png'); images{75} = imread('vector75.png'); images{76} = imread('vector76.png'); images{77} = imread('vector77.png'); images{78} = imread('vector78.png'); images{79} = imread('vector79.png'); images{80} = imread('vector80.png'); images{81} = imread('vector81.png'); images{82} = imread('vector82.png'); images{83} = imread('vector83.png'); images{84} = imread('vector84.png'); images{85} = imread('vector85.png'); images{86} = imread('vector86.png'); images{87} = imread('vector87.png'); images{88} = imread('vector88.png'); images{89} = imread('vector89.png'); images{90} = imread('vector90.png'); images{91} = imread('vector91.png'); images{92} = imread('vector92.png'); images{93} = imread('vector93.png'); images{94} = imread('vector94.png'); images{95} = imread('vector95.png'); images{96} = imread('vector96.png'); images{97} = imread('vector97.png'); images{98} = imread('vector98.png'); images{99} = imread('vector99.png'); images{100} = imread('vector100.png'); images{101} = imread('vector101.png'); images{102} = imread('vector102.png'); images{103} = imread('vector103.png'); images{104} = imread('vector104.png'); images{105} = imread('vector105.png'); images{106} = imread('vector106.png'); images{107} = imread('vector107.png'); images{108} = imread('vector108.png'); images{109} = imread('vector109.png'); images{110} = imread('vector110.png'); images{111} = imread('vector111.png'); images{112} = imread('vector112.png'); images{113} = imread('vector113.png'); images{114} = imread('vector114.png'); images{115} = imread('vector115.png'); images{116} = imread('vector116.png'); images{117} = imread('vector117.png'); images{118} = imread('vector118.png'); images{119} = imread('vector119.png'); images{120} = imread('vector120.png'); images{121} = imread('vector121.png'); images{122} = imread('vector122.png'); images{123} = imread('vector123.png'); images{124} = imread('vector124.png'); images{125} = imread('vector125.png'); images{126} = imread('vector126.png'); images{127} = imread('vector127.png'); images{128} = imread('vector128.png'); images{129} = imread('vector129.png'); images{130} = imread('vector130.png'); images{131} = imread('vector131.png'); images{132} = imread('vector132.png'); images{133} = imread('vector133.png'); images{134} = imread('vector134.png'); images{135} = imread('vector135.png'); images{136} = imread('vector136.png'); images{137} = imread('vector137.png'); images{138} = imread('vector138.png'); images{139} = imread('vector139.png'); images{140} = imread('vector140.png'); images{141} = imread('vector141.png'); images{142} = imread('vector142.png'); images{143} = imread('vector143.png'); images{144} = imread('vector144.png'); images{145} = imread('vector145.png'); images{146} = imread('vector146.png'); images{147} = imread('vector147.png'); images{148} = imread('vector148.png'); images{149} = imread('vector149.png'); images{150} = imread('vector150.png'); images{151} = imread('vector151.png'); images{152} = imread('vector152.png'); images{153} = imread('vector153.png'); images{154} = imread('vector154.png'); images{155} = imread('vector155.png'); images{156} = imread('vector156.png'); images{157} = imread('vector157.png'); images{158} = imread('vector158.png'); images{159} = imread('vector159.png'); images{160} = imread('vector160.png'); images{161} = imread('vector161.png'); images{162} = imread('vector162.png'); images{163} = imread('vector163.png'); images{164} = imread('vector164.png'); images{165} = imread('vector165.png'); images{166} = imread('vector166.png'); images{167} = imread('vector167.png'); images{168} = imread('vector168.png'); images{169} = imread('vector169.png'); images{170} = imread('vector170.png'); images{171} = imread('vector171.png'); images{172} = imread('vector172.png'); images{173} = imread('vector173.png'); images{174} = imread('vector174.png'); images{175} = imread('vector175.png'); images{176} = imread('vector176.png'); images{177} = imread('vector177.png'); images{178} = imread('vector178.png'); images{179} = imread('vector179.png'); images{180} = imread('vector180.png'); images{181} = imread('vector181.png'); images{182} = imread('vector182.png'); images{183} = imread('vector183.png'); images{184} = imread('vector184.png'); images{185} = imread('vector185.png'); images{186} = imread('vector186.png'); images{187} = imread('vector187.png'); images{188} = imread('vector188.png'); images{189} = imread('vector189.png'); images{190} = imread('vector190.png'); images{191} = imread('vector191.png'); images{192} = imread('vector192.png'); images{193} = imread('vector193.png'); images{194} = imread('vector194.png'); images{195} = imread('vector195.png'); images{196} = imread('vector196.png'); images{197} = imread('vector197.png'); images{198} = imread('vector198.png'); images{199} = imread('vector199.png'); images{200} = imread('vector200.png'); % create the video writer with 1 fps writerObj = VideoWriter('200fr_10new.avi'); writerObj.FrameRate = 1; writerObj.Quality = 100; % set the seconds per image secsPerImage=[0.1:0.1:20.0]; % open the video writer open(writerObj); % write the frames to the video for u=1:length(images) % convert the image to a frame frame = im2frame(images{u}); for v=1:secsPerImage(u) writeVideo(writerObj, frame); end end % close the writer object close(writerObj); fprintf('Video done in %.1f s. Enjoy! \n\n', toc) end
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)