Fixing "Can't Concatenate Videos" Error in FFmpeg

Abstract: Resolve FFmpeg concatenation errors by ensuring input files share identical codecs, resolutions, and frame rates before merging.

Created: 2026-08-20 by

The "Can't concatenate videos" error in FFmpeg usually occurs because the input files have mismatched codecs, resolutions, or container formats. To resolve this, you must first ensure all source videos are identical in technical specifications, then use either the concat demuxer for simple merging or the filter_complex method for more complex operations.

Understanding the Root Cause

FFmpeg is incredibly powerful, but it demands strict consistency when joining media files. The most common reason for concatenation failure is that the video streams do not share the same codec, resolution, frame rate, or pixel format. For instance, trying to merge an H.264 file with a VP9 file directly often results in errors because the underlying binary structures differ significantly. Even if both files are MP4 containers, differences in audio sample rates or video dimensions will prevent FFmpeg from stitching them together seamlessly. Another frequent culprit is the use of variable frame rates (VFR). Many screen recordings and mobile phone videos use VFR to save space. FFmpeg’s default concat demuxer expects constant frame rates (CFR) for reliable synchronization. If your inputs are VFR, the timestamps may drift, causing playback issues or immediate failures during the muxing process. Additionally, using incompatible protocols or corrupted headers in the input files can trigger generic concatenation errors. It is essential to verify that each individual video plays correctly on its own before attempting any batch processing.

Verifying File Consistency

Before running any merge commands, inspect your files using ffprobe. This tool provides detailed metadata about each stream. Run the following command to check a single file:
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height,r_frame_rate,sample_rate -of default=noprint_wrappers=1:nokey=1 input.mp4
Compare the output for all files you intend to merge. They must match exactly in codec name, width, height, and frame rate. If the audio streams differ, check the sample rate and channel layout as well. Any discrepancy here indicates that you cannot use the simplest concatenation methods and must proceed to re-encoding or advanced filtering.

Method 1: Using the Concat Demuxer

The concat demuxer is the fastest way to join files without re-encoding, provided they are compatible. This method requires creating a text file that lists your inputs. Create a file named list.txt with the following content:
file 'input1.mp4'
file 'input2.mp4'
file 'input3.mp4'
Ensure each line starts with file followed by a space and the path to the video. Use absolute paths if you encounter permission errors. Then, run the merge command:
ffmpeg -f concat -safe 0 -i list.txt -c copy output.mp4
The -c copy flag tells FFmpeg to stream-copy the audio and video data, avoiding quality loss and speeding up the process. The -safe 0 option allows the use of relative paths in older versions of FFmpeg, though modern versions handle this automatically. If this fails, check the error message; it will likely point to a specific stream mismatch that needs addressing via Method 2.

Method 2: Re-encoding with Filter Complex

When files are incompatible, you must re-encode them into a uniform format. This is slower but guarantees compatibility. Use the filter_complex option to chain filters that normalize the streams. Suppose you have two videos with different resolutions. You need to scale them to a common size and pad them if necessary.
ffmpeg -i input1.mp4 -i input2.mp4 -filter_complex "[0:v]scale=1920:1080,format=yuv420p[v0];[1:v]scale=1920:1080,format=yuv420p[v1];[v0][0:a][v1][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" output.mp4
In this example, both video streams are scaled to 1920x1080 and converted to the YUV 4:2:0 pixel format, which is widely supported. The concat filter then joins these normalized streams. Adjust the scale parameters to match your desired output resolution. Always specify the pixel format explicitly to avoid artifacts, especially when dealing with high-bit-depth sources.

Handling Audio Synchronization

Audio mismatches are often overlooked. If your videos have different sample rates, FFmpeg may fail to mux them. Add an audio filter to resample the streams to 44100 Hz or 48000 Hz, which are standard values. Include aresample=48000 in your filter chain to ensure smooth audio playback across the concatenated result. For more troubleshooting on general FFmpeg stability, you might find our guide on resolving startup crashes helpful, although that addresses different system-level errors. See Fixing FFmpeg: Application unable to start (0xc0000005) Issue for background context on environment variables.

Common Pitfalls and Solutions

One common issue is the "unsafe" warning when using relative paths. While newer versions of FFmpeg allow this, sticking to absolute paths in your list.txt file eliminates ambiguity. Another pitfall is forgetting to close the quotes around filenames containing spaces. Always wrap paths in single quotes within the list file. If you encounter infinite loops during processing, it may indicate a corrupted header rather than a concatenation issue. Reviewing loop-related problems can help distinguish between bad inputs and bad commands. Check Troubleshooting FFmpeg Infinite Loop Video Issue if your terminal hangs unexpectedly. Finally, always test your output file after creation. Play it back to ensure there are no black frames, audio desyncs, or abrupt cuts at the join points. If the result looks correct, you have successfully resolved the concatenation error.

Frequently Asked Questions

Why does FFmpeg say "Invalid data found when processing input"?

This error typically means one of your source files is corrupted or has an unsupported header structure. Verify the file integrity by playing it in a standard media player like VLC. If it fails there too, the file itself is damaged and needs to be replaced or repaired before concatenation.

Can I concatenate videos with different durations?

Yes, FFmpeg can easily join videos of varying lengths. The concat demuxer simply appends the second file immediately after the first ends. However, ensure that the technical specs (codec, resolution) remain consistent, regardless of the time length difference.

What is the best format for intermediate files?

MP4 with H.264 video and AAC audio is the most universally compatible container format. If you need to re-encode, stick to these codecs to ensure maximum playback support across devices and web platforms. Avoid proprietary or obscure codecs unless specifically required by your workflow.

How do I fix audio desync after concatenation?

Audio desync often results from differing sample rates or timestamp inconsistencies. Ensure all inputs share the same sample rate, such as 48kHz. If desync persists, try adding the -async 1 flag to the output command to force FFmpeg to adjust audio timestamps dynamically.

Is there a limit to how many videos I can concatenate?

There is no hard-coded limit in FFmpeg, but performance degrades with very large numbers of files due to memory usage and buffer overhead. For batches over 100 files, consider splitting the task into smaller groups or using a script to automate multiple sequential concatenations.

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