How do I make an animated GIF file from an AVI file?

9 views (last 30 days)
I would like to use MMREADER and IMWRITE to create an animated GIF file from an AVI file.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
In order to convert code from an AVI file to an animated GIF file, follow the steps below. The AVI file is the input and named 'mode15_600p78Hz.avi' and the output file is the GIF file 'test1.gif.'
vrinfo = aviinfo('mode15_600p78Hz.avi');
filename = 'test1.gif';
mov1 = mmreader('mode15_600p78Hz.avi');
vidFrames = read(mov1);
for n = 1:vrinfo.NumFrames
[imind,cm] = rgb2ind(vidFrames(:,:,:,n),255);
if n == 1;
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end

More Answers (0)

Categories

Find more on Animation in Help Center and File Exchange

Tags

No tags entered yet.

Products

Community Treasure Hunt

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

Start Hunting!