3.0

3.0 | 3 ratings Rate this file 78 downloads (last 30 days) File Size: 2.39 KB File ID: #17463

Movie to GIF Converter

by Nicolae Cindea

 

09 Nov 2007 (Updated 09 Nov 2007)

Code covered by BSD License  

Convert movie to GIF

Download Now | Watch this File

File Information
Description

Movie2Gif ver. 1.0
==================
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 submission has inspired the following:
gif_add_frame
MATLAB release MATLAB 7.3 (R2006b)
Other requirements If you have Image Processing Toolbox you can replace my function aRGB2IND with the function rgb2ind.
Zip File Content  
Other Files movie2gif.m,
aRGB2IND.m
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
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...');

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);

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?

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.

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);.

10 Sep 2009 BD Knight

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);

Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
movie Nicolae Cindea 22 Oct 2008 09:34:17
gif Nicolae Cindea 22 Oct 2008 09:34:17
movie2gif Nicolae Cindea 22 Oct 2008 09:34:17
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com