FFmpeg recipe
FFmpeg: Frame-Accurate Trim of an MP4 (Re-Encode)
When stream-copy snaps to the nearest keyframe and you need exact-frame precision, re-encoding is the answer. Slower, but sample-accurate.
Command
ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:30 -c:v libx264 -crf 23 -c:a aac -b:a 192k -y output.mp4Prefer no terminal?
Use the Video Trimmer in your browser
What each flag does
| -i | Input file. Can be a video, audio, or image. Repeat for multiple inputs. |
|---|---|
| -ss | Seek to this timestamp (HH:MM:SS or seconds). Place BEFORE -i for fast keyframe seek; AFTER -i for sample-accurate seek. |
| -to | Stop at this timestamp (absolute, not duration). Use -t instead for a relative duration. |
| -c:v | Video codec for output. e.g. libx264, libx265, libvpx-vp9. |
| -crf | Constant Rate Factor — quality target (lower = better, larger file). 23 is visually lossless for libx264. |
| -c:a | Audio codec for output. e.g. aac, libmp3lame, copy. |
| -b:a | Audio bitrate, e.g. 192k. |
| -y | Overwrite output file without confirmation. |
Notes & gotchas
- Place -ss AFTER -i for sample-accurate seek (slower, decodes to the timestamp).
- CRF 23 is visually lossless. CRF 18 is mathematically near-lossless but file size doubles.
Related recipes
Trim · MP4
Trim an MP4 with FFmpeg using stream-copy for lossless, instant output. Copy-paste command with explanations.
Convert MOV → MP4 · MOV → MP4
Convert MOV to MP4 with FFmpeg using H.264 video and AAC audio. CRF 23 default keeps quality visually identical.
Convert HEVC → H.264 · HEVC → H.264
Convert HEVC (H.265) video to H.264 with FFmpeg so it plays on Windows, in Chrome, and on older Macs.
Convert MKV → MP4 · MKV → MP4
Convert MKV to MP4 with FFmpeg using stream-copy. Remuxes the H.264 / AAC streams without re-encoding.