Code covered by the BSD License  

Highlights from
Movie to GIF Converter

4.3

4.3 | 10 ratings Rate this file 81 Downloads (last 30 days) File Size: 2.98 KB File ID: #17463
image thumbnail

Movie to GIF Converter

by

 

09 Nov 2007 (Updated )

Convert a matlab movie to a GIF

| Watch this File

File Information
Description

Movie2Gif

Matlab movie to GIF Converter.

Syntax: movie2gif(mov, gifFile, prop, value, ...)

The list of properties is the same like for the command 'imwrite' for the
file format gif:

'BackgroundColor' - A scalar integer. This value specifies which index in
                    the colormap should be treated as the transparent
                    color for the image and is used for certain disposal
                    methods in animated GIFs. If X is uint8 or logical,
                    then indexing starts at 0. If X is double, then
                    indexing starts at 1.

'Comment' - A string or cell array of strings containing a comment to be
            added to the image. For a cell array of strings, a carriage
            return is added after each row.

'DelayTime' - A scalar value between 0 and 655 inclusive, that specifies
              the delay in seconds before displaying the next image.

'DisposalMethod' - One of the following strings, which sets the disposal
                   method of an animated GIF: 'leaveInPlace',
                   'restoreBG', 'restorePrevious', or 'doNotSpecify'.

'LoopCount' - A finite integer between 0 and 65535 or the value Inf (the
              default) which specifies the number of times to repeat the
              animation. By default, the animation loops continuously.
              For a value of 0, the animation will be played once. For a
              value of 1, the animation will be played twice, etc.

'TransparentColor' - A scalar integer. This value specifies which index
                    in the colormap should be treated as the transparent
                    color for the image. If X is uint8 or logical, then
                    indexing starts at 0. If X is double, then indexing
                    starts at 1

Acknowledgements

This file inspired Gif Add Frame.

MATLAB release MATLAB 7.8 (R2009a)
Other requirements If you have Image Processing Toolbox you can replace my function aRGB2IND with the function rgb2ind.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (15)
18 Mar 2014 Ashkan

great script. I had to modify the last line.

18 Jan 2014 Ki

great script. Just have one question, seems that the gil will not record anything in the frame title or xlabel or ylabel.

29 Aug 2013 Ming

This is the best best best best one.

19 Jul 2013 Abi mehranian

Great code!

07 Mar 2013 matt dash  
20 Jul 2012 Nolan C

Gets the job done!

19 Nov 2011 bart Blockmans

I don't understand why this code hasn't got 5 stars yet. It does what it has to do and is very simple. Very good work!

17 Apr 2011 Søren

Very useful - with Keith's and Scott's recommendations.

20 May 2010 Kye

nevermind, misread documentation

10 Sep 2009 Eric T

Doesn't work for me get the following error:
??? Error using ==> reshape
To RESHAPE the number of elements must not change.

Error in ==> aRGB2IND at 12
RGBij = double(reshape(RGB(i,j,:), 1, 3)./255);

Error in ==> movie2gif at 75
[IND, map] = aRGB2IND(RGB);

27 Feb 2008 Scott Burnside

Useful code. I too had to make Keith's mod to initialize the waitbar. Btw, since .gif is 8-bit color you can use [IND, map] = rgb2ind(RGB,256);.

22 Feb 2008 john chavez

whoops, i just realized that I was playing the gifs in quicktime. They play fine with firefox or some other web-browser.

22 Feb 2008 john chavez

nice code, but I am having trouble with the color in the gifs that are being created. The movie images I am using have a lot of different colors in them, but the gifs that are created only have shades of white, light blue, dark blue, and black. I am using a bunch of fill3 commands with lighting effects to create the images, so maybe its a problem with the colormap?

20 Feb 2008 Evan Variano

Thank you - This is a useful piece of code. To make it work, I had to make the change suggested by Keith Brodie (thanks Keith!). Also, when switching to the internal function rgb2ind, I had to supply an additional input, namely 128. In other words, this line shows up twice in my final code:

[IND, map] = rgb2ind(RGB,128);

30 Nov 2007 Keith Brodie

Thanks - worked for me. I had to add one line to the movie2gif.m to initialize the waitbar handle in the case of nargin==2.

if (nargin == 2)
h = waitbar(0, 'Generate GIF file...');

Updates
10 Oct 2011

This new version fixed some small bugs.

22 Apr 2013

Some small bug fixes and ameliorations.

Contact us