The Correct Way to Pass Encoding without FPS Reset using ffmpeg

Abstract: Prevent FFmpeg from resetting the frame rate by omitting the -r flag to preserve original timing during encoding.

Created: 2026-10-03 by
To preserve the original framerate during FFmpeg encoding without triggering a reset or resampling, you must avoid using the -r flag on the input stream, as this forces frame rate conversion. Instead, rely on the encoder’s native handling of timestamps by omitting explicit rate overrides and ensuring your output container supports variable frame rates if necessary. This approach maintains temporal integrity while allowing for efficient compression.

Understanding the Problem with -r

Many users encounter issues where their video’s frame rate changes unexpectedly after processing. The most common culprit is the misuse of the -r flag. When placed before an input file, such as ffmpeg -i input.mp4 -r 30 output.mp4, the -r flag acts as an input filter. It tells FFmpeg to resample the incoming frames to match the specified rate. If the source is 60fps and you specify -r 30, FFmpeg will drop half the frames or duplicate them to fit the new rate, fundamentally altering the timing. Even if you intend to keep the same rate, explicitly setting it can sometimes cause conflicts with how the encoder handles variable frame rates (VFR) versus constant frame rates (CFR). This behavior is distinct from setting the output rate. Placing -r after the input but before the output can set the *output* frame rate, but it still implies a conversion process if the internal timestamps do not align perfectly. For pure passthrough or encoding that respects the source timing, manual intervention via -r is often the wrong tool.

Correct Passthrough Strategies

The goal is to let FFmpeg read the source timestamps and write them directly to the output without modification. There are two primary scenarios: copying streams without re-encoding, and encoding while preserving the source frame rate structure. Scenario A: Stream Copying If you do not need to change the codec or quality, use the copy command. This is the fastest method and guarantees zero alteration of any metadata, including frame rate.
ffmpeg -i input.mp4 -c copy output.mp4
This command copies all streams (video, audio, subtitles) exactly as they are. No decoding or encoding occurs, so the frame rate remains identical to the source. Scenario B: Re-encoding with Preserved FPS When you must re-encode (e.g., changing H.264 to H.265), you should avoid forcing a specific frame rate. Modern encoders like libx264 and libx265 are designed to handle the input frame rate intelligently. By omitting -r, you allow the encoder to use the timestamps provided by the demuxer.
ffmpeg -i input.mp4 -c:v libx265 -crf 28 output.mp4
In this example, the video is re-encoded using the HEVC codec with a Constant Rate Factor (CRF) of 28. Because no -r flag is present, FFmpeg preserves the original timing. If the source is Variable Frame Rate (VFR), the output will also be VFR, which is often preferred for streaming platforms and modern playback devices.

Handling Variable Frame Rate (VFR) Sources

A common misconception is that VFR is "bad." In reality, VFR is highly efficient because it uses fewer frames during static scenes and more during action. However, some older players or editing software struggle with VFR files. If your target platform requires Constant Frame Rate (CFR), you have two choices: convert to CFR during encoding or convert after encoding. Converting to CFR During Encoding If you specifically need a fixed frame rate (e.g., for broadcast standards), use the setpts filter or the fps video filter *after* the input but *before* the encoder. Note that this is different from -r.
ffmpeg -i input.mp4 -vf fps=fps=24 -c:v libx264 -crf 23 output.mp4
Here, the fps filter converts the video to a constant 24fps. This is an active conversion, not a passthrough. Use this only when a fixed rate is required. If you want to keep the original rate but ensure compatibility, consider converting to CFR in a second pass or using a tool dedicated to VFR-to-CFR conversion, such as mkvmerge or specialized scripts. Why 'fps=keep' Fails Some guides suggest using -vf fps=keep. This option does not exist in standard FFmpeg builds. Attempting to use it results in an error. The correct way to "keep" the frame rate is simply to not touch it at all. Let the encoder inherit the timestamp information from the input stream.

Verifying Your Output

After encoding, always verify the frame rate of the output file to ensure it matches your expectations. You can use FFprobe, a companion tool to FFmpeg, to inspect the stream details.
ffprobe -v error -select_streams v:0 -show_entries stream=r_frame_rate -of default=noprint_wrappers=1:nokey=1 output.mp4
This command extracts the raw frame rate value from the video stream. Compare this output with the source file’s frame rate. If they match, your passthrough was successful. If they differ, review your command line for any stray -r flags or filter settings that might have forced a conversion.

Common Pitfalls

  • Mixing Input and Output Flags: Ensure -r is not interpreted as an input resampler. Always check the position of flags relative to -i.
  • Container Limitations: Some containers, like MP4, have strict requirements for certain codecs. While H.264/H.265 support VFR in MP4, other formats may not. Check container documentation if you experience sync issues.
  • Audio Sync Drift: If you change video frame rates significantly, audio drift may occur. Using -async 1 or adjusting audio timestamps can help, but preserving the original video rate avoids this entirely.
For more advanced encoding techniques, you might explore how to handle low-bitrate audio efficiently, which often complements video optimization strategies. See FFmpeg vs LAME: Equivalent MP3 Encoding with Low CBR for insights into maintaining quality across media types. Additionally, if you are working with multiple streams, understanding how FFmpeg handles them is crucial to avoiding errors. Refer to Error Starting Encoding with Multiple Video Streams in FFmpeg for troubleshooting complex inputs.

Frequently Asked Questions

Does removing -r guarantee the frame rate stays the same?

Yes, omitting the -r flag allows FFmpeg to preserve the source timestamps and frame rate structure. The encoder will use the incoming frame timing unless explicitly told otherwise by filters or output flags.

What if my source is VFR and I need CFR?

You must actively convert it using the fps video filter, such as -vf fps=fps=30. There is no automatic "passthrough" mode for VFR-to-CFR conversion; it requires resampling the frames to a constant interval.

Can I use -r after the input to set output rate?

While technically possible, it is discouraged because it can conflict with the encoder’s internal handling of timestamps. It is safer to use video filters like fps= for explicit rate changes or rely on the encoder’s defaults for preservation.

How do I check if my video is still VFR after encoding?

Use ffprobe to inspect the stream. Look for the avg_frame_rate and r_frame_rate fields. If they differ significantly or show fractional values typical of VFR, the variable rate has been preserved.

Why did my video lose sync after encoding?

Sync issues often arise when video frame rates are changed without adjusting audio timestamps. Preserving the original frame rate by avoiding -r prevents this mismatch, ensuring audio and video remain aligned.

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