Build1 distinct publisher3 min readPublished
The -ss with -c copy recipe cannot start anywhere except a keyframe, so it hands back a clip that is early and long. Reading the keyframe list first lets you re-encode only the head and tail and copy the rest.
The Engineer · Build desk

Compiled by The EngineerSomething wrong?How this is made
Start with the arithmetic on the failure. The published keyframe listing for the test file shows keyframes at 0, 2.002, 4.004 and 6.006 seconds [9]. Extend that cadence and the sixth keyframe lands at 12.012, which is 0.388 seconds before the requested 12.4 start, and 0.388 is exactly the excess in the ffprobe duration of the copied clip [2][1]. That excess is the distance back to the previous keyframe, and every frame in the output is shifted earlier by the same amount [3].
Nothing is broken. Stream copy moves compressed packets without decoding them, and most frames in a compressed stream only describe the difference from their neighbours, so a keyframe is the only legal starting packet [4]. FFmpeg snaps backwards to the nearest one and reports the duration it actually wrote [4][2].
The segmentation that fixes it is three spans: start to the first keyframe after start, re-encoded; that keyframe to the last keyframe before end, stream copied; that keyframe to end, re-encoded [7]. If start and end sit inside the same GOP there is no middle, and the whole short span gets re-encoded [8].
Now treat the headline cost figure as a claim about someone else's content. "Encoding cost proportional to two GOPs instead of the whole file" [6] is a statement about GOP length, not about the script. At the sample cadence two GOPs is 4.004 seconds, which against a two-hour source is about 0.06 percent of the timeline [2]. Two conditions have to hold for that to transfer. The GOP has to be short relative to the clip you are cutting. The fragments have to be concat-compatible with the copied middle, which means matching codec, resolution, pixel format and audio parameters, read off the source rather than hardcoded in your preset [12].
The second condition is where a screen-recording library bites. Screen recorders and some camera output emit keyframes on scene change only, and the gaps there can be 30 seconds or more [10]. A 20-second request on that content fits inside a single GOP, the middle disappears, and you are back to re-encoding the span in full [3]. The keyframe distribution of your ingest, not the trim code, is the real spec for the feature [10].
The details in the helper code are worth reading before you copy any of it. Frame rate is parsed by splitting r_frame_rate on the slash so that "30000/1001" becomes 29.97, with no eval() anywhere near a string that came out of ffprobe [13]. The keyframe search uses a 1e-6 tolerance rather than comparing floats exactly [14]. The execFile call sets maxBuffer to 64 MB, which is the config line that tells you how large a full packet listing gets [15]. On a two-hour file that probe reads every packet header: fast, because it does not decode, but not free, so it wants caching per asset [11]. Keyframe positions never change for a given file, which makes this the rare cache with no invalidation story to write [11].
The published excerpt stops mid-import in smart-trim.js, so the fragment encoder flags and the concat invocation are not shown [17]. The transferable part is the segmentation rule and the probe, both of which the author reports working on FFmpeg 7.x and 8.x as well as the 9.0 "Lei" build it was tested against [16].
Ranked by verification strength, evidence, and original report placement.
The smart-trim approach probes keyframe positions with ffprobe, re-encodes only the head and tail fragments, stream copies everything between them, and concatenates the three, giving frame accurate output with encoding cost proportional to two GOPs instead of the whole file.
Given a requested [start, end]: head is start to the next keyframe after start, re-encoded; middle is that keyframe to the last keyframe before end, stream copied; tail is that keyframe to end, re-encoded.
Running ffmpeg -ss 12.4 -i input.mp4 -t 20 -c copy fast.mp4 produced a file for which ffprobe reports start_time=0.000000 and duration=20.388000, against a requested 20 seconds starting at 12.4.
The copied clip is long by the distance from the requested start back to the previous keyframe, and every frame in it is shifted earlier than the user asked for.
If start and end fall inside the same GOP there is no middle, and the whole short span is re-encoded.
The published text ends mid-import inside smart-trim.js, at the point where keyframeTimes is being imported, so the fragment encoder flags and the concat invocation are not shown.
Follow any of these and your For You feed starts watching them — no settings page required.
Evidence-backed comparisons of source perspectives and observed adoption signals. Read the methodology
Which Builder, Operator, and Investor concerns the observed source mix emphasized—not a truth score.
Evidence, demonstrated adoption, hype gap, incentives, and confidence are assessed independently, each on its own current evidence. How these are measured.
Reproducible commands, unverified end state
The core failure mode is demonstrated with copy-pasteable ffmpeg/ffprobe commands and concrete output (start_time=0.000000, duration=20.388000), and the keyframe listing internally corroborates the 0.388 s overshoot via the 2.002 s cadence. Against that, the evidence base is one article from one publisher, the technique's concat step is missing because the listing is truncated, and no timing or quality measurements back the two-GOP cost claim.
No adoption signal
The only adoption-adjacent datapoint is the author's self-reported test environment (FFmpeg 9.0 'Lei', Node 22.x). There are no deployments, downloads, repository, benchmark results or user reports in the supplied material, so adoption cannot be scored.
Mildly overstated
The mechanism claim (copy trims snap to keyframes) is solidly evidenced and the design is standard, well-understood FFmpeg practice, so the headline is close to aligned. The small positive gap comes from promising 'frame accurate output' at two-GOP cost while the concat invocation is missing from the published text, no timing comparison is given, and the article's own scene-change caveat implies the two-GOP saving evaporates for an important class of source material.
Low commercial pressure
The material is an individual developer tutorial on a community publishing platform with no product, vendor, sponsor, pricing or licensing interest visible in the text; the only incentive present is the ordinary attention incentive of a how-to post, which shows up as a confident framing ('frame accurate') for an unfinished listing.
Moderate
High confidence in the technical mechanism and the reported measurement because both are reproducible and internally consistent; low confidence about outcomes, performance and real-world use because the cluster has a single source, the implementation is truncated, and no adoption evidence exists.
build
Every viewer hits your HLS key endpoint in the same second, and almost nobody tests it1 distinct publisher
build
FFmpeg.wasm ships, but budget for a watchdog: one in ten heavy jobs deadlocked in silence1 distinct publisher
build
A GAN beauty filter is a device budget allocation, not a feature toggle1 distinct publisher
build
912MB to 108MB is mostly typing now, and that weakens the base-image excuse in review1 distinct publisher
Distinct publishers with included, body-backed reporting in this cluster.
dev.to
1 article · August 27, 2026