Trimming Start of Video Generates Negative Presentation Timestamps with FFmpeg

Abstract: Resolve negative presentation timestamps when trimming video start with FFmpeg by using -copyts and -start_at_zero.

Created: 2026-09-01 by
To avoid negative presentation timestamps (PTS) when trimming the start of a video with FFmpeg, you must reset the timestamp counter after the initial seek. Simply using -ss before -i is not enough because it only shifts the input time; the output container still references the original file’s timeline. You need to combine an early seek for speed with the -copyts and -start_at_zero flags, or use the setpts filter if re-encoding. This ensures the new video starts at zero rather than inheriting negative offsets from the cut point.

Understanding Negative Presentation Timestamps

When you trim a video by specifying a start time, FFmpeg reads frames starting from that offset. However, the internal Presentation Timestamps (PTS) are absolute values relative to the original source file. If your source video has a PTS of 0 at its beginning, and you start reading at 10 seconds, the first frame you process might have a PTS of 10. When FFmpeg writes this to a new container, it expects timestamps to start at 0. If the container format or codec requires strictly non-negative timestamps starting from zero, FFmpeg may generate errors or invalid files if the PTS values are not adjusted.

This issue often manifests as playback glitches, audio desynchronization, or errors like "negative pts" during muxing. It is particularly common when working with formats that do not support negative timestamps natively or when the output stream needs to be compatible with strict players. The core problem is that the output stream inherits the absolute timing of the input stream without normalization.

Method 1: Using -ss Before -i with Copyts and Startatzero

The most efficient method avoids re-encoding by performing a fast seek. Placing -ss before -i tells FFmpeg to seek to the specified time immediately upon opening the file, which is much faster than seeking after decoding begins. To fix the timestamp issue, you must explicitly tell FFmpeg to copy the original timestamps and then reset them to start at zero.

  1. Use Early Seek: Place -ss immediately before the input file argument. This triggers a keyframe-based seek, which is significantly faster than post-decoding seeks.
  2. Copy Timestamps: Add the -copyts flag. This preserves the original PTS values from the input stream in the output stream initially.
  3. Reset to Zero: Add the -start_at_zero flag. This instructs FFmpeg to subtract the initial PTS value from all subsequent timestamps, effectively shifting the timeline so the first frame is at 0.
  4. Stream Copy: Use -c copy to avoid re-encoding, ensuring lossless quality and fast processing.
ffmpeg -ss 10 -i input.mp4 -c copy -copyts -start_at_zero output.mp4

In this command, -ss 10 seeks to the 10-second mark. -copyts ensures the PTS values are carried over exactly as they appear in the input. -start_at_zero then adjusts these values so that the first frame of the output has a PTS of 0. This combination is robust and works with most modern FFmpeg versions. For more details on extracting specific segments, see Extract Video Segment Timestamps with FFmpeg: Command and Options.

Method 2: Re-encoding with Setpts Filter

If Method 1 fails due to container limitations or if you are already re-encoding, you can use the setpts video filter. This method explicitly manipulates the timestamp expression for each frame. While slower than stream copying, it offers precise control over the timeline and guarantees that the output timestamps are mathematically normalized.

The setpts filter accepts an expression that calculates the new PTS based on the current PTS. By dividing the current PTS by the stream's timebase and multiplying it back, or simply resetting the base, you can force the timestamps to start at zero. The standard expression for resetting timestamps is PTS-STARTPTS. This subtracts the PTS of the first frame from every subsequent frame, resulting in a new timeline that starts at 0.

ffmpeg -i input.mp4 -ss 10 -to 20 -vf "setpts=PTS-STARTPTS" -c:v libx264 -c:a aac output.mp4

Here, -ss 10 and -to 20 define the segment boundaries. The -vf "setpts=PTS-STARTPTS" applies the filter to the video stream. Note that if you also have an audio stream, you should apply a similar filter to it, such as -af "asetpts=PTS-STARTPTS", to prevent audio-video sync issues. This approach is essential when dealing with complex filters or when the output format does not support the -start_at_zero flag.

Common Pitfalls and Best Practices

Avoid placing -ss after -i if you want fast trimming. A post-decoding seek forces FFmpeg to decode all frames from the beginning of the file up to the cut point, which is extremely slow for long videos. Always prefer -ss before -i for keyframe-accurate cuts.

Another common mistake is assuming that -c copy will always preserve the correct timing. Without -copyts and -start_at_zero, the output file may retain the original absolute timestamps, leading to negative values if the start time was trimmed. Always verify the output with a media player or by checking the stream metadata using ffprobe.

Additionally, be aware that some older containers or codecs may not handle negative timestamps gracefully even if FFmpeg generates them. In such cases, the setpts filter is the safest bet because it modifies the data directly before muxing. For related techniques on manipulating video properties, you might find Extracting Specific Frame Index using FFmpeg's Timestamp (PTS) useful for understanding how PTS values are structured.

Frequently Asked Questions

Why does my video play too fast after trimming?

This usually happens if the duration metadata is not updated correctly while the frame rate remains unchanged. Ensure you are using -copyts and -start_at_zero together, or applying setpts=PTS-STARTPTS. These methods adjust both the timestamps and the perceived duration of the stream.

Can I use -ss after -i to avoid negative timestamps?

No, placing -ss after -i performs a precise seek but does not inherently reset timestamps. It still results in absolute PTS values that may be negative relative to the new start time if not handled by additional flags like -start_at_zero. It is also significantly slower for long videos.

How do I fix negative timestamps in the audio stream?

You must apply the asetpts filter to the audio stream just as you do for video. Use -af "asetpts=PTS-STARTPTS" alongside your video filter. Failure to synchronize both streams will result in audio drift or silence.

Is -start_at_zero supported in all FFmpeg versions?

The -start_at_zero flag was introduced in FFmpeg 4.2. If you are using an older version, you must use the setpts filter method instead. Check your version with ffmpeg -version to determine compatibility.

What if I get a "non-monotonous DTS" error?

This error indicates that the decoded timestamps are not increasing monotonically, often due to imperfect seeking or B-frames. Using -ss before -i helps minimize this, but you may also need to add -framedrop or use the setpts filter to enforce monotonicity.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More