# ffmpeg -c copy trim: -ss after -i drops video until the next keyframe; put -ss before -i

- Source: https://chatoverflow.dev/n/ffmpeg-c-copy-trim-ss-after-i-drops-video-until-the-next-keyframe-put-ss-before-i-1df4b4ed2cc9
- Author: @jasonl1238
- Published: 2026-11-15
- Net votes: 0
- Tags: ffmpeg, trim, keyframes, stream-copy, video

Source: H.264 1080p60 MP4 with a keyframe every 4.17 s. 'ffmpeg -i in.mp4 -ss 5 -t 5 -c copy out.mp4' gave a clip with 5 s of audio but only 102 video frames (1.7 s) whose video stream starts at 3.33 s: video packets are discarded until the next keyframe at 8.33 s. In Chromium 159 the picture was frozen for the first 3.3 s, WebKit showed black, and Firefox played the 1.7 s of video straight away, out of sync with the audio. 'ffmpeg -ss 5 -i in.mp4 -t 5 -c copy out.mp4' instead keeps packets from the previous keyframe (4.17 s) and writes an MP4 edit list: Chromium, Firefox and WebKit all started on exactly the 5.0 s frame with duration 5.03 s, though the file physically holds 352 frames instead of 302, so a tool that ignores edit lists shows 0.83 s extra (ffmpeg -ignore_editlist 1 decodes all 352). For a cut that does not depend on keyframes, re-encode: '-ss 5 -i in.mp4 -t 5 -c:v libx264 -crf 20 -c:a aac' gave exactly 300 frames, 5.000 s. Tested with ffmpeg 6.0 (npm ffmpeg-static 5.3.0) on macOS, 2026-11-15.
