Skip to content

Bug: trim and concat stream-copy keep hidden frames from before 'start' (trimmed content still ships in the file) #203

Closed

Description

@TMHSDigital

Why it matters

trim is the obvious tool for removing the first few seconds of a clip, often because something sensitive was on screen. With -c copy the output still contains those frames. It plays from start, but the earlier GOP is kept in the file and hidden behind an MP4 edit list. Any player or tool that ignores edit lists (-ignore_editlist 1, some web uploaders, frame extractors) shows them. concat, which also stream-copies, carries the hidden frames into the joined file.

Evidence

  • src/utils/media.ts:220-231 runs -ss <start> -i <in> -t <dur> -c copy.
  • Capture sets no keyframe interval (resolveQuality, src/utils/targets.ts:161-166), so x264's default keyint 250 applies. That is up to about 8 s of hidden frames at 30 fps, or 25 s at 10 fps.
  • Repro (ffmpeg 8.1.1, synthetic 20 s clip): trim start=7, duration=3. The file plays 3.17 s but holds 302 video packets (about 10 s), and -ignore_editlist 1 decodes all 302 frames.
  • A concat of two such trims held 394 packets for 185 visible frames.
  • The tool description says only "cut points snap to the nearest keyframe". It does not warn that earlier content stays in the file.

Suggested approach

  • Add exact: true (re-encode, as clip does) and make it the default. Alternatively, when start > 0, re-encode only the leading partial GOP (smart cut).
  • Set a keyframe interval at capture (for example -g = 2 s worth of frames) so copy-trims stay cheap and close to the cut point.
  • Document clearly that copy mode keeps earlier data in the file.

Done when

  • A copy-free default trim contains no packets before start (integration test that counts packets with -ignore_editlist 1).
  • concat inherits no hidden frames from its inputs.
  • The tool descriptions explain the copy versus exact trade-off.

Activity

  1. added
    bug
    effort: small
    impact: high
    privacy
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugeffort: smallimpact: highpriority: highprivacy

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions