Skip to content

Suggestion: Add a precise trimming toggle using trim/atrim filters #212

Description

@kli2013

Hi author, thank you for developing and maintaining this useful WebM clipping script.

I noticed that the script currently uses --start and --end parameters to specify the clip range. This approach relies on keyframe (I-frame) seeking, which means the actual starting point can be several seconds to tens of seconds earlier than the specified time when the video has a large GOP. This makes it impossible to achieve frame-exact clipping.

I understand this may be for performance reasons (fast seeking), but in scenarios where precise clipping is needed (e.g., capturing a specific frame, aligning subtitles), this limitation becomes noticeable.

I experimented by adding a toggle option (precise_trim) to the script. When enabled, it uses lavfi-trim + setpts for video and atrim + asetpts for audio to achieve frame-exact trimming, while removing --start/--end. In my tests, it does achieve frame-level precision, though encoding startup is slightly slower (due to decoding extra frames before the target point).

I'd like to ask:

  1. Is using --start/--end by default a performance consideration, or are there other reasons (e.g., compatibility)?
  2. Have you considered adding an optional toggle so users can choose between "fast" and "precise" modes based on their needs?
  3. Is my approach of adding trim filters reasonable, or do you have a better implementation suggestion?

If this feature would be valuable to the project, I'd be happy to submit a PR or provide my modification details.

Thanks again for your work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions