Media2GifMedia2Gif
v2.4 · OPEN SOURCE

Turn any film into a wall of perfectly tagged GIFs.

Media2Gif is a command-line tool that walks through a movie file, finds every quote in the subtitles, and exports a GIF for each one — sized to fit Giphy with the line burned in. Run it once and you have hundreds of upload-ready clips, every filename already encoding the movie, timestamp, and quote.

Auto size-targeting (under 4 MB by default)SRT + embedded subtitle tracksFilenames pre-tagged for Giphy
39
GIFs in this gallery
32
Quotes captured
3min
Of footage processed
3.7MB
Average GIF size
// 02. CORPUS

Films fully converted.

Every quote from these films has been processed end-to-end and uploaded to the Media2Gif Giphy channel. More on the way.

// 04. THE PIPELINE

From .mkv to gallery in five passes.

The script reads your subtitle track, walks the timeline at your interval, and re-encodes each clip in a tightening loop until it lands inside your size budget.

01
INGEST

Read the film

ffprobe inspects the source. External SRT or embedded track, your call. HDR sources can be flattened with --noHDR.

02
SCAN

Walk the timeline

Step through at --interval seconds. If the slice contains a quote, expand to the full line. Otherwise capture a 5-second clip.

03
BURN

Stamp the quote

Subtitle gets typeset to your color, size, stroke, and padding. ALL CAPS or italic if you want. Cropped-safe by design.

04
FIT

Squeeze under budget

Iterative re-encode: tweak palette, framerate, and scale until the file lands as close to --maxFilesize as possible.

05
EMIT

Tag and save

Filename encodes movie, start, end, and sanitized quote. Sidecar JSON optional. Auto-bucketing into batch_NNN folders.

// 05. THE INTERFACE

25 flags. One command.

Subtitle styling, size targeting, batch organization, randomization, and HDR handling all live behind clearly-named flags. Sensible defaults — opinionated where it matters.

~/projects/media2gif — bash
# generate gifs for every quote in the film
$ python make_gifs.py \
--movie "Heat.mp4" \
--outputFolder gifs \
--maxFilesize "15mb" \
--quotes true \
--subtitleColor "white" \
--subtitleSize 35 \
--textBorder 3 \
--uppercase \
--saveJson
→ Heat-Start[00-12-04]-End[00-12-08]-Quote[dontletyourselfgetattached].gif 3.92 MB
→ Heat-Start[00-18-22]-End[00-18-25]-Quote[theactionisthejuice].gif 3.88 MB
→ Heat-Start[00-24-11]-End[00-24-15]-Quote[aguytoldmeoncedontletyou].gif 3.95 MB
→ Heat-Start[00-31-58]-End[00-32-02]-Quote[iamaloneIamnotlonely].gif 3.91 MB
[OK] 142 gifs · 9,604 quotes · 3.7 MB avg
/
FlagDefaultWhat it does
--movie<PATH>Path to the movie file
--subtitles<PATH>External .srt subtitle file (optional — embedded tracks auto-detected)
--outputFolder<DIR>Where the GIFs land. Relative paths sit next to the movie.
--interval<SEC>5Seconds between non-quote GIFs
--startTime<hh:mm:ss>00:00:00When to start scanning
--maxFilesize<SIZE>Target size, e.g. 15mb. Script downsamples until it fits.
--quotes<BOOL>trueInclude subtitle quotes burned into GIFs
--randomQuotePick a random quote (or random time if --quotes false)
--randomTimesGenerate from random start times rather than walking the film
--subtitleColor<COLOR>whiteSubtitle text color
--subtitleSize<PX>16Subtitle font size
--textBorder<PX>2Black stroke width around text
--textPadding<PX>5Margin so text never crops
--bottomPadding<PX>Distance from bottom of frame
--uppercaseForce ALL CAPS subtitles
--italicizefalseItalicize subtitle text
--trailingPeriod<BOOL>trueKeep trailing periods in quotes
--noHDRConvert HDR source to SDR before encoding
--boostColors<PCT>Boost saturation/contrast on the whole GIF
--boostFrameColors<PCT>Boost colors per-frame before assembly
--saveJsonWrite a sidecar JSON with quote, start, end, filename
--outputBatchFolderSize<N>Auto-bucket into batch_001, batch_002… every N gifs
--listSubtitleTracksPrint embedded subtitle tracks and exit
--subtitleTrack<INDEX>Pick which embedded track to burn in
--debugSave every iteration of the size-optimization loop
// 06. QUICKSTART

Three steps. Five minutes.

ffmpeg does the encoding. Python orchestrates. Clone, install, point it at a movie.

01Install ffmpeg

# install Homebrew, then:
brew install ffmpeg

02Clone & venv

git clone https://github.com/MartinBarker/Media2Gif
cd Media2Gif

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

03Run it

python make_gifs.py \
  --movie "movie.mkv" \
  --outputFolder gifs \
  --maxFilesize "15mb" \
  --uppercase \
  --saveJson