Using FFmpeg -start_at_zero With Copy Timestamps

When trimming or slicing media files without re-encoding in FFmpeg, preserving original timestamps often results in media containers that start playback at an offset rather than zero. This article explains how to properly apply the -start_at_zero flag alongside -copyts to shift your presentation timestamps so that your output file begins cleanly at 00:00:00 while maintaining stream synchronization and avoiding re-encoding.

The Problem with -copyts

When you cut a video using stream copy (-c copy) and preserve timestamps (-copyts), FFmpeg keeps the original Presentation Time Stamps (PTS). For example, if you extract a segment starting at minute 00:02:00, the first frame in the output file retains the 00:02:00 timestamp.

Many media players and web platforms handle non-zero starting timestamps poorly, resulting in frozen initial frames, incorrect duration displays, or playback failures.

The Solution: -start_at_zero

The -start_at_zero flag works exclusively as an output option alongside -copyts. It shifts the PTS of all streams by subtracting the timestamp of the first packet, effectively resetting the beginning of the file to zero while preserving the relative distance and synchronization between subsequent audio and video frames.

Command Syntax

To use -start_at_zero correctly, place your seek parameters, enable stream copying, and supply both -copyts and -start_at_zero before specifying the output filename:

ffmpeg -ss 00:01:30 -to 00:02:45 -i input.mp4 -c copy -copyts -start_at_zero output.mp4

Important Usage Rules

  • Must Pair with -copyts: The -start_at_zero option has no effect on its own. FFmpeg by default attempts to rewrite timestamps from zero unless -copyts tells it to preserve the input stream's timing.
  • Output Placement: Place -start_at_zero after the input specifications and before the output file path.
  • Keyframe Alignment: Because stream copying (-c copy) does not decode or re-encode video, cuts only occur cleanly on keyframes (I-frames). If your seek point (-ss) does not align with a keyframe, the video may display blank frames or freeze momentarily at timestamp zero until the first keyframe is reached. To ensure smooth playback, seek to an exact keyframe or omit -c copy if re-encoding is acceptable.