Trimming
Trimming (Video Clip Extraction)
The operation of selecting a specific time range from a video and extracting or keeping only that segment, discarding the content before the start point and after the end point.
技術的詳細
Lossless trimming (stream copy) cuts at keyframe boundaries without re-encoding, preserving original quality but limiting precision to the nearest keyframe (typically 2-10 second intervals). Frame-accurate trimming requires re-encoding the segments between cut points and the nearest keyframes. FFmpeg performs lossless trim with: ffmpeg -ss START -to END -i input.mp4 -c copy output.mp4. Placing -ss before -i enables fast seeking using the container index. Browser-based trimming with MediaRecorder captures portions of video playback, while FFmpeg.wasm enables true frame-level cutting client-side. The most common pitfall is audio-video sync drift when cutting at non-keyframe positions without re-encoding.
例
```html <!-- Trimming: HTML5 video with format fallback --> <video controls preload="metadata"> <source src="video.webm" type="video/webm; codecs=vp9,opus"> <source src="video.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> ```