All posts

FFmpeg Mosh

FFmpeg Mosh is the fastest way to create datamosh effects without manual keyframe surgery. It strips away the normal motion prediction reset that happens between video cuts, forcing frames to bleed across edits in strange, glitch-heavy ways. Perfect for rapid prototypes, creative experiments, or automated video pipelines, FFmpeg’s mosh capabilities can be chained, scripted, and scaled. At its core, datamoshing depends on manipulating P-frames and I-frames. P-frames store only changes between im

Free White Paper

Mosh: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

FFmpeg Mosh is the fastest way to create datamosh effects without manual keyframe surgery. It strips away the normal motion prediction reset that happens between video cuts, forcing frames to bleed across edits in strange, glitch-heavy ways. Perfect for rapid prototypes, creative experiments, or automated video pipelines, FFmpeg’s mosh capabilities can be chained, scripted, and scaled.

At its core, datamoshing depends on manipulating P-frames and I-frames. P-frames store only changes between images, while I-frames are complete stills that reset compression. When you remove or skip I-frames, the codec keeps blending motion vectors from previous frames into new ones. FFmpeg gives you low-level control to drop I-frames, duplicate P-frames, and export the glitch stream straight to file without intermediate renders.

A basic FFmpeg mosh command looks like this:

ffmpeg -i input.mp4 -vf setpts=PTS-STARTPTS -vcodec copy -avoid_negative_ts 1 output.mp4

For more control, isolate frames with selective re-encoding:

Continue reading? Get the full guide.

Mosh: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.
ffmpeg -i input.mp4 -filter_complex "[0:v]select='eq(pict_type,PICT_TYPE_P)',setpts=N/FRAME_RATE/TB[v]"-map "[v]"-an output_mosh.mp4

This tells FFmpeg to keep only predictive frames and discard keyframes, triggering mosh behavior. You can wrap this in shell scripts or Python bindings for batch processing.

Engineers using FFmpeg mosh in production need to watch for codec compatibility. H.264 and MPEG4 are common choices; VP9 works but may require different flags. Bitrate control matters: too low and you lose detail, too high and glitches fade. Experiment with GOP length to amplify effects. Short GOPs reduce mosh intensity; extended GOPs multiply it.

Integration into existing pipelines is straightforward. FFmpeg runs on Linux, macOS, and Windows, works headless, and can be triggered from CI/CD. With containerized builds, you can mosh at scale. Store intermediate outputs in lossless formats like ProRes, then export final moshed segments in compressed form.

The power of FFmpeg mosh comes from precision. You decide exactly which frames survive and which frames dissolve. You control codec flags, GOP sizes, and output specs. With this approach, datamoshing turns into a repeatable process rather than a manual artform.

Test it. Break your footage. Make it glitch. Deploy it. Then take the pipeline further — see it live in minutes at hoop.dev.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts