Media interpolate

From damionrashford/media-os · View interactive version

Media interpolate is an AI agent skill from the GitHub repository damionrashford/media-os. AI frame interpolation with open-source + commercial-safe models: RIFE (MIT, current best real-time open-source interpolator; ECCV 2022; available as rife-ncnn-vulkan prebuilt CLI on macOS/Linux/Windows), FILM (Apache 2.0, Google 2022, excels on large motion), PractCL (MIT, practical cascaded refine

How to use this skill

Skill file

Media Interpolate

Context: $ARGUMENTS

Quick start

When to use

Step 1 — Pick a model

| Model | License | Best for | Form |

|----------|------------|---------------------------------------------|-------------------------------|

| RIFE | MIT | General video, anime, real-time, default | rife-ncnn-vulkan prebuilt CLI + PyTorch repo |

| FILM | Apache-2.0 | Large motion (sports, fast pans), stills | Python/TensorFlow inference |

| PractCL | MIT | Research, cascaded refinement experiments | Python/PyTorch |

Decision rules:

  1. Default to RIFE via rife-ncnn-vulkan — Vulkan cross-platform (NVIDIA, AMD, Intel, Apple Silicon via MoltenVK), no Python, fastest install.
  2. Scene with large motion (fast pans, sports, explosions, big occlusions) → FILM.
  3. Tweening two still images with very different content → FILM (designed for near-duplicate photos a year apart).
  4. Pure anime → RIFE models rife-anime-v4.x are tuned for it.

Do NOT use: DAIN (research-only license). It pre-dates RIFE and is slower; RIFE supersedes it at every benchmark this skill cares about.

Step 2 — Install the binary / package

scripts/interp.py install <model> prints the exact platform-specific command. It does not auto-install.

# RIFE (ncnn-vulkan prebuilt — recommended)
# Download release zip from: https://github.com/nihui/rife-ncnn-vulkan/releases
# Unzip; add the folder to PATH. Includes models: rife-v2.3 / v2.4 / v3.0 / v3.1 / v4 / v4.6 / anime

# FILM (Python + TensorFlow)
uv pip install tensorflow mediapy
git clone https://github.com/google-research/frame-interpolation

# PractCL
git clone https://github.com/fatheral/PractCL
uv pip install torch opencv-python numpy

Recipe A — RIFE 2x frame-doubling on a video

# Frame pipeline: extract frames -> RIFE 2x on folder -> remux.
# The script does this end-to-end:
uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py video \
  --model rife --in clip_24fps.mp4 --out clip_60fps.mp4 \
  --fps 60 --rife-model rife-v4.6

What happens under the hood:

# (1) extract PNGs at source fps
ffmpeg -i clip_24fps.mp4 -qscale:v 1 -qmin 1 -qmax 1 -vsync 0 in/%08d.png
# (2) RIFE fills the gaps (pick 2x, or directly target -f output-frames)
rife-ncnn-vulkan -i in -o out -m rife-v4.6 -n 0
# -n 0 = auto (2x). For arbitrary target fps, use the script, which computes N.
# (3) remux at target fps + original audio
ffmpeg -framerate 60 -i out/%08d.png -i clip_24fps.mp4 \
       -map 0:v -map 1:a? -c:v libx264 -preset slow -crf 17 -pix_fmt yuv420p \
       -c:a copy -movflags +faststart clip_60fps.mp4

Recipe B — FILM on a video with big motion

python frame-interpolation/eval/interpolator_cli.py \
  --pattern "frames_in/*.png" \
  --model_path /path/to/film_net/Style/saved_model \
  --times_to_interpolate 1 \
  --output_video

--times_to_interpolate is log2 of the multiplier: 1 doubles (2x), 2 quadruples (4x), 3 eight-times.

Recipe C — PractCL

python PractCL/test.py --input in/ --output out/ --factor 2

Step 3 — Slow-motion (keep audio unmodified)

interp.py slow-mo doubles / quadruples / 8x's the number of frames while keeping the output framerate unchanged (so content plays back slower):

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py slow-mo \
  --model rife --in action.mp4 --out action_slow2x.mp4 --factor 2

Implementation: extract frames at src_fps, RIFE by factor, remux at src_fps. Audio is dropped (slowing the video without slowing the audio produces a pitch mismatch). Restore audio afterwards with ffmpeg-audio-filter atempo=1/factor if desired.

Step 4 — Tween between two stills

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py images \
  --model rife before.png after.png --out middle.png
# Generate N intermediate frames
uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py images \
  --model rife before.png after.png --out-dir sequence/ --count 8

Under the hood, RIFE ncnn accepts two-image mode with -0 first.png -1 second.png -o middle.png. For N>1 the script repeatedly subdivides (midpoint of midpoint).

Gotchas

Examples

Example 1: 24fps film clip → 60fps (smoother motion)

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py video \
  --model rife --in film_24.mp4 --out film_60.mp4 --fps 60

Example 2: 4x slow-motion

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py slow-mo \
  --model rife --in action.mp4 --out action_4x_slow.mp4 --factor 4
# Audio was dropped. To keep it in sync at 1/4 speed:
ffmpeg -i action.mp4 -vn -af "atempo=0.5,atempo=0.5" -c:a aac audio_slow.m4a
ffmpeg -i action_4x_slow.mp4 -i audio_slow.m4a -c copy -shortest action_4x_final.mp4

atempo is capped at 0.5–2.0 per instance; chain atempo=0.5,atempo=0.5 for 0.25x.

Example 3: 60 intermediate frames between two product photos (FILM)

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py images \
  --model film before.png after.png --out-dir tween/ --count 60
ffmpeg -framerate 30 -i tween/%04d.png -c:v libx264 -crf 18 -pix_fmt yuv420p tween.mp4

Example 4: Anime → 60fps with the anime-tuned model

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py video \
  --model rife --in ep01_24p.mkv --out ep01_60p.mp4 \
  --fps 60 --rife-model rife-anime-v4.6

Example 5: Check which binaries are available

uv run ${CLAUDE_SKILL_DIR}/scripts/interp.py check

Troubleshooting

Error: `rife-ncnn-vulkan: command not found`

Cause: binary not installed.

Solution: Grab a release from https://github.com/nihui/rife-ncnn-vulkan/releases, unzip, add the folder to PATH. Or uv run .../interp.py install rife.

Error: `failed to load model: rife-v4.6`

Cause: -m model name expects a directory named rife-v4.6 under the binary's models/ path.

Solution: The ncnn release zip includes several models pre-staged. If you moved the binary without its models/ folder, re-unzip and keep them together. Or pass -m /abs/path/to/rife-v4.6.

Video has doubled length / slow-motion when you wanted smooth-60

Cause: remuxed the 2x frames at the source fps instead of the target fps. ffmpeg -framerate 24 -i out/... plays 2x frames at 24 fps → 2x duration.

Solution: use -framerate 60 (or the target you asked for) on the reassembly step. The driver handles this — don't roll your own.

Output has A/V desync after slow-mo

Cause: the slow-mo path kept the original audio at native rate while the video timeline stretched.

Solution: either drop audio (script default) or run atempo=1/factor on audio and remux.

RIFE looks great on most frames but smears during a fast cut

Cause: the two input frames span a scene change. The model tries to interpolate between unrelated content.

Solution: run media-scenedetect to find cuts, then process each scene independently (or skip interpolation across cuts).

FILM `Unable to load model`

Cause: --model_path not pointing at a saved_model directory (must contain saved_model.pb + variables/).

Solution: download from the FILM releases and point at the right style subfolder (e.g. .../Style/saved_model).

Reference docs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.