CV

Video Compress.

Two small scripts around FFmpeg for long screen and session recordings: a compressor that encodes on the graphics card to HEVC and a subtitle burner. The compressor has a quick test mode that judges the settings on a short slice, and the burner has a single-frame preview and a check of the subtitle file before the long encode.

Media & entertainment

Year
2026
Personal project
My part
Sole developer
Core stack
3 technologies
Claude Code, FFmpeg, Python
Website
Not public
No public link

My role

I wrote both scripts alone, for my own use on long session recordings.

Capabilities

Compressor

  • GPU HEVC encoding tuned for file size, with one quality option
  • Test mode: a two-minute slice from the middle and a projected size for the full file
  • Frame mode that keeps sound in step on variable frame rate recordings
  • Result written to a new file with sizes before and after
  • Drag and drop launcher that keeps the window open

Subtitle burner

  • Single-frame preview at any second, with the nearest line named when the second is a pause
  • Subtitle file checked for broken timestamps and overlaps before encoding
  • Audio copied untouched, with a stricter quality target for the second encode
  • Output duration compared with the source after the run

Patterns and decisions

  • Two Python scripts on the standard library around ffmpeg and ffprobe. Nothing else to install.
  • Both encode on the graphics card to HEVC and leave resolution and frame rate alone. Only the bitrate changes.
  • The original is never overwritten. Every result goes to a new file next to it, with a suffix in the name.
  • A launcher batch file takes a video dropped on it, runs the compressor with the default settings and keeps the window open, so the final size stays on screen. The common case is one drag.

Cases

Encoder settings picked for size, with one knob left. Recordings of long sessions are huge and mostly static, so the goal was a much smaller file with no visible loss. I set the hardware HEVC encoder to a slow high-quality preset, constant-quality variable bitrate and a ceiling on the rate. Two settings cost real debugging time. The video bitrate has to be zero beside the quality target, otherwise the encoder ignores the quality and falls back to plain bitrate control. Frame mode is passthrough, because screen recorders often write a variable frame rate, and normalising it adds duplicate frames and pulls the sound away from the picture toward the end of a long file. The only option is the quality target. The default sits between a near-original value and one that smears fast motion and small text. There is no CPU fallback on purpose: without the card a long video would take hours, and that is a decision for the person running it.

A test mode that judges the settings before a long run. A wrong quality value found after a full encode wastes the whole run. Test mode cuts a two-minute slice from the middle of the file, because the middle is an ordinary scene and not a title card, and encodes only that. It scales the size of the slice by the full duration and prints the expected size of the finished file. The figure is an estimate: a calm slice understates it and a busy one overstates it. I look at the slice, adjust the target if needed and start the real run.

Subtitle burn-in with a preview frame. Burned-in text cannot be switched off or corrected afterward, and the encode is long, so the font size has to be right first. The preview mode renders one frame at any second and prints the line that should be on screen. When the second falls in a pause, it says so and names the nearest line. The first version drew the opening line of the file over every frame, which looked like a broken filter. The seek was resetting the timeline, so I kept the original timestamps. The filter also reads the file name as part of its own syntax, which breaks on a drive colon and Cyrillic, so the script copies the subtitle file to a temporary folder under a plain name. Before encoding, the file is checked for broken timestamps, overlaps and an end earlier than the start, so a bad file fails in a second. The audio is copied untouched, and the quality target is stricter than in the compressor, since this is a second encode. Afterward the output length is compared with the source.

Core stack

AI engineering

Languages & markup

Media & real time