Tool 'smart-trim' achieves frame-accurate FFmpeg cuts by re-encoding only clip edges
A developer has released a Node.js utility called smart-trim that solves a longstanding FFmpeg limitation where stream-copy trimming can only cut on keyframe boundaries, causing inaccurate clip lengths. The tool uses ffprobe to locate keyframes and splits a requested trim into three segments: a re-encoded head, a stream-copied middle, and a re-encoded tail. Only the short fragments at the start and end of the clip are re-encoded, preserving quality while keeping processing fast. The segments are then joined using FFmpeg's concat demuxer to produce a single output file. The project has been tested with FFmpeg 9.0 'Lei', released on August 4, 2026, and Node.js 22.x, and is written as an ESM module.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in