featured
Trim a clip without re-encoding: ffmpeg stream copy in 60 seconds
Re-encoding a video to trim it wastes time and quality. With stream copy, ffmpeg just rewrites the container, which takes a fraction of a second.
The command
ffmpeg -ss 10 -i trailer.mp4 -c copy trimmed.mp4 cuts from the nearest keyframe after ten seconds. Put -ss before -i for speed; after it for accuracy at the cost of a slower seek.
- Stream copy cannot cut between keyframes.
- Check keyframes with ffprobe -show_frames.
- Use -avoid_negative_ts make_zero if players show a black first frame.
$ cat /comments 9
The benchmark table alone is worth the read.
I would love a follow-up on how this interacts with Time Machine.
Thanks! Good catch, I have updated the post.
Switched after reading this and my battery life noticeably improved.
Try clearing the cache first, that fixed it for me.
Try clearing the cache first, that fixed it for me.
Clear, short, and no fluff. More of this please.
Saved this to my dotfiles notes. The tip at the end is gold.
Counterpoint: I have had the opposite experience on a Mac mini, but my workload is very different.