How FFmpeg -copyts Affects Stream Synchronization

This article explains how the -copyts (copy timestamps) option in FFmpeg influences audio and video stream synchronization. By default, FFmpeg resets input timestamps to start from zero, which can sometimes disrupt the alignment between different media tracks. Enabling -copyts preserves the original container timestamps, ensuring that the relative timing between audio, video, and subtitle streams remains intact, which is critical for maintaining synchronization in complex editing workflows.

Default FFmpeg Behavior vs. -copyts

When FFmpeg processes an input file, its default behavior is to demux the packets and shift their presentation timestamps (PTS) so that the output stream starts at or very close to zero. While this is helpful for standard playback compatibility, it strips away the absolute timing data of the source media.

By applying the -copyts option, you instruct FFmpeg to bypass this shifting process. The tool copies the exact timestamps from the input container directly to the output muxer.

Why -copyts is Crucial for Stream Synchronization

Using -copyts directly impacts stream synchronization in several key scenarios:

Potential Issues and Complementary Options

While -copyts is vital for synchronization, using it blindly can sometimes cause playback issues, as some media players struggle to decode files that do not start near zero.

To resolve this, -copyts is frequently paired with the -start_at_zero option. When used together: 1. -copyts preserves the exact relative synchronization and distance between the audio and video packets. 2. -start_at_zero shifts the entire synchronized timeline back so that the earliest stream starts at zero, satisfying player requirements without causing synchronization drift.