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.mp4
Prefer no terminal?
Use the Video Trimmer in your browser
Open Video Trimmer

What each flag does

-iInput file. Can be a video, audio, or image. Repeat for multiple inputs.
-ssSeek to this timestamp (HH:MM:SS or seconds). Place BEFORE -i for fast keyframe seek; AFTER -i for sample-accurate seek.
-toStop at this timestamp (absolute, not duration). Use -t instead for a relative duration.
-c:vVideo codec for output. e.g. libx264, libx265, libvpx-vp9.
-crfConstant Rate Factor — quality target (lower = better, larger file). 23 is visually lossless for libx264.
-c:aAudio codec for output. e.g. aac, libmp3lame, copy.
-b:aAudio bitrate, e.g. 192k.
-yOverwrite 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