FFmpeg Concat: Download Videos with yt-dlp and Merge Them

Abstract: Merge multiple yt-dlp downloaded videos into a single file using FFmpeg concat demuxer without re-encoding.

Created: 2026-08-25 by
You can merge multiple videos downloaded with yt-dlp by creating a text file listing the absolute paths of your media files and then running an FFmpeg command that utilizes the concat demuxer. This method ensures that the resulting video maintains consistent codecs, resolutions, and frame rates across all segments, providing a seamless playback experience without re-encoding overhead if the source files are compatible.

Preparing Your Downloaded Files

The first step in this process is ensuring that your video segments are ready for concatenation. When you download videos using yt-dlp, they are often saved as separate files. To merge them successfully, these files must share identical technical properties, including codec type, resolution, frame rate, and audio sample rate. If the files differ significantly, FFmpeg will either fail or produce a corrupted output.

It is highly recommended to use the same format options when downloading each part. For instance, if you download Part 1 and Part 2 using identical yt-dlp arguments, they are much more likely to be compatible. You can verify compatibility by checking the file details using a tool like MediaInfo or by attempting a simple test merge of just two files before processing the entire list.

Creating the Concat List File

FFmpeg’s concat demuxer requires a specific input format: a plain text file where each line defines a file path. This approach is superior to using the concat protocol directly on the command line because it handles spaces in filenames and directory structures more reliably. You need to create a file, typically named mylist.txt, containing the absolute paths to your videos.

Each entry in the list must follow the syntax file 'path/to/video.mp4'. Note the single quotes around the path; these are mandatory if your file path contains spaces. Below is an example of how this text file should look:

file '/home/user/videos/part1.mp4'
file '/home/user/videos/part2.mp4'
file '/home/user/videos/part3.mp4'

Ensure there are no blank lines between entries, as this can cause the demuxer to throw errors. The order of the files in this text document determines the final sequence of the merged video. Always use absolute paths (starting with / on Linux/Mac or C:\ on Windows) to avoid confusion regarding the current working directory.

Executing the Merge Command

Once your list file is prepared, you can run the FFmpeg command to merge the content. The core instruction involves specifying the input as the list file rather than individual video files. The command structure is straightforward:

ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

Let's break down the critical components of this command. The flag -f concat tells FFmpeg to use the concat demuxer. The option -safe 0 is crucial for security reasons; it allows FFmpeg to read files from outside the current directory or with names that might otherwise be considered unsafe, such as those starting with hyphens. Without this flag, FFmpeg may reject your list file if it contains relative paths or certain special characters.

The -c copy argument instructs FFmpeg to stream-copy the audio and video streams without re-encoding them. This makes the process extremely fast and preserves the original quality. If you encounter issues with container formats that do not support direct stream copying (such as mixing MP4 and MKV), you may need to remove -c copy and allow FFmpeg to re-encode, though this will take significantly longer and reduce quality.

Troubleshooting Common Errors

Users often face specific errors during this process. One common issue is the "Unsafe file name" error. As mentioned, adding -safe 0 resolves this. Another frequent problem is mismatched codecs. If you receive an error stating that the codec is not supported for concatenation, it means your source files have different parameters. In such cases, you must convert all files to a uniform standard before merging. You can use yt-dlp again with specific format flags to ensure consistency, or use FFmpeg to remux the files into a common container like MP4 with H.264 video and AAC audio.

If you are working on Windows, ensure that your command prompt or PowerShell window has access to the directory where mylist.txt resides, or provide the full path to the list file in the command. On Linux and macOS, check file permissions to ensure FFmpeg can read the listed video files.

Alternative Approaches

While the concat demuxer is the most robust method for complex merges, some users prefer simpler approaches for basic tasks. For example, if you are only joining two files with identical formats, you can sometimes use the concat protocol directly in the input string, but this is less flexible. Additionally, if you need to combine silent videos with audio tracks, refer to our guide on Concatenating Videos with Silent Audio using FFmpeg for specialized handling of audio streams. Similarly, if you are dealing with portrait and landscape orientations, see Creating Portrait and Landscape Video Set Images with FFmpeg to understand how aspect ratios affect the final output.

Frequently Asked Questions

Can I merge videos with different resolutions?

No, FFmpeg cannot directly concatenate videos with different resolutions using the concat demuxer. You must first resize or crop all videos to the same dimensions using filters before merging them.

Why does my merged video have no audio?

This usually happens if the audio codecs in the source files are incompatible or if the -c copy flag fails due to container limitations. Try removing -c copy to force re-encoding, or ensure all source files use AAC audio.

Is it necessary to use absolute paths?

While relative paths work, absolute paths are strongly recommended to prevent errors related to the current working directory. They ensure FFmpeg can locate the files regardless of where you run the command from.

How do I handle large numbers of video files?

You can generate the mylist.txt file automatically using shell commands. On Linux or macOS, you can use a loop to write each file path to the list, avoiding manual entry for dozens of segments.

What if I get an 'unsafe file name' error?

Add the -safe 0 flag to your FFmpeg command. This disables the safety checks that prevent FFmpeg from accessing files with potentially dangerous names or locations.

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