Back to Projects

Video to GIF Converter

FFmpeg Python 3.13 MoviePy Batch Automation

Project Category: Individual Project (Personal Productivity Tool)

Convert MP4 videos to optimized GIFs with exact size and speed constraints. Automatically scales resolution and adjusts frame rates to meet target file sizes (1-50MB). Perfect for social media, presentations, and web content.

Key Features

Exact Size Control

Specify target size (1-50MB) - tool automatically optimizes to meet constraint

Project Category: Individual Project (Personal Productivity Tool)

Speed Adjustment

0.1x to 2.0x playback speed control for dramatic or time-lapse effects

Project Category: Individual Project (Personal Productivity Tool)

Smart Resolution Scaling

Automatically reduces resolution to fit size while maintaining quality

Project Category: Individual Project (Personal Productivity Tool)

Frame Rate Optimization

Adjusts FPS dynamically based on target size and video length

Project Category: Individual Project (Personal Productivity Tool)

Constraint Validation

Warns if target size is unrealistic for video duration

Project Category: Individual Project (Personal Productivity Tool)

Batch Processing

Process multiple videos with same settings

Project Category: Individual Project (Personal Productivity Tool)

Project Category: Individual Project (Personal Productivity Tool)

Parameters

Parameter Range Default Description
Target Size 1 - 50 MB 10 MB Maximum GIF file size
Speed 0.1x - 2.0x 1.0x Playback speed multiplier
Resolution Auto-scaled Original Reduced automatically if needed
FPS 5 - 30 fps 15 fps Frames per second (auto-adjusted)

Usage

Batch File (Recommended)

mp4togif.bat "path\to\video.mp4"

Python Script (Advanced)

# Basic conversion (10MB, 1.0x speed)
py converter.py "video.mp4"

# Custom size and speed
py converter.py "video.mp4" --size 5 --speed 1.5

# Slow motion
py converter.py "video.mp4" --size 20 --speed 0.5

Optimization Examples

Social Media (Twitter/Discord)

py converter.py "clip.mp4" --size 10 --speed 1.0
# Result: 480p @ 15fps, perfect for social platforms

Project Category: Individual Project (Personal Productivity Tool)

High Quality Presentation

py converter.py "demo.mp4" --size 50 --speed 1.0
# Result: 720p @ 24fps, excellent quality for slides

Project Category: Individual Project (Personal Productivity Tool)

Thumbnail/Preview

py converter.py "preview.mp4" --size 2 --speed 1.5
# Result: 360p @ 10fps, fast-loading preview

Project Category: Individual Project (Personal Productivity Tool)

Slow Motion Effect

py converter.py "action.mp4" --size 30 --speed 0.5
# Result: Half-speed playback, maintains quality

Project Category: Individual Project (Personal Productivity Tool)

Output Structure

Video_to_GIF_Converter/
 extracted_gifs/
    video_name_10MB_1.0x.gif
    video_name_5MB_1.5x.gif
    ...

How It Works

  1. Load Video: Read video using MoviePy, extract duration and dimensions
  2. Validate Constraints: Check if target size is realistic (warns if < 0.5MB/sec)
  3. Calculate Parameters:
    • Estimate required resolution based on size/duration ratio
    • Adjust FPS dynamically (lower for long videos, higher for short clips)
    • Apply speed multiplier to duration
  4. Generate GIF: Use FFmpeg with optimized palette for compression
  5. Verify Output: Check final size, warn if significantly over/under target

Troubleshooting

GIF is too large

GIF looks pixelated

Conversion fails

Use Cases

Requirements

View on GitHub

Project Category: Individual Project (Personal Productivity Tool)