I created a GIF using ffmpeg using the following command:
ffmpeg -i foo.mp4 -ss 00:00:18 -t 00:00:06 -pix_fmt rgb24 bar.gif
However, the resulting bar.gif was over 300 MB in size while the movie file foo.mp4 was about 15 MB!
What gives?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A comprehensive answer to this question is difficult :-p In a nutshell, it comes down to how the compression is done in each format.
In GIF animations, each frame is conceptually a separate GIF image. All of the GIF images are then stored in one large GIF file, with instructions to play the frames back with a certain delay between the frames. To optimize the frames, you can run the GIF through a program that can delete duplicate information from one frame to the next (the GIMP “Animation Optimize” filter is a good way to do that: GIMP – Simple Animations).
On the other hand, video formats like MP4 have a different approach. They assume that frames are going to be similar, and only store the difference between two frames. Additionally, the amount of data for each frame is limited to the specified video bitrate given when you begin the compression. Lossy compression is performed to bring the video file down to the desired bitrate. To further optimize the video file, most video transcoders include options for “two-pass encoding”. This runs through the video twice: the first time it just gathers information about what parts of the file are more complex, and then the second time it compresses every not complex portion of the video more aggressively.
There are many other optimizations as part of the video encoding process that are just plain missing from the GIF file format. Also, it’s worth pointing out that a GIF animation is going to be limited to a 256-color palette, which can result in image dithering. MP4 uses something more similar to a JPEG compression for the video frames (although with additional optimizations targeted specifically at video… the old MJPEG format was basically just stacks of JPEG images, just as GIF animations are stacks of GIF images).
If you can give more information about your specific use case, we may be able to help you find a better solution.