TISKBAF
  • 🖥️Linux OS
    • Useful Linux commands
    • To get a list of the dependencies of a package
    • Reset a Forgotten Root Password
    • How to Kill a Port in Linux
    • How to Install/Reinstall Linux GRUB Menu
    • Concatenate mp4 files using FFmpeg
    • Command to stop mirroring screens
    • Command to Run when Trash Won’t Empty
    • Prey Configuration Command (via Terminal)
    • Prey Configuration Command (via Terminal)
  • 🖥️Windows OS
    • Custom Profile Badges
      • badge-maker
      • shields.io - static badges
    • How to kill a task via terminal on Windows
    • Find and terminate a Windows Process by Port
    • The Complete List of Command Prompt (CMD) Commands
    • youtube-dl Usage
    • WSA/Google Play Services Reference Information
    • Windows Update Blocker (Windows Services Blocker)
    • Windows 11 Shell commands with friendly names
    • Wifi not automatically connecting on start-up when Ethernet is connected
    • To install many APK files at once
    • To get Firefox to remember logged in accounts
    • Spicetify Commands
    • Speech Recognition Commands
    • Simpletask [Simple] Documentation
    • Sideload Apps in Windows Subsystem for Android from APK Files
    • SetUserFTA Utility
    • Screensaver not starting even though it is configured correctly
    • Run Keys Registry Location
    • Rainmeter Config Definitions
    • Pushover
    • Program Folder Locations
    • Add an exclusion to Windows Security (or just turn off real-time protection)
    • Reddit RSS Feeds
    • Portainer on Windows
    • PGP: Encrypt & sign emails in a few clicks
    • Permanently Remove OneDrive from Windows
    • IRC NickServ Commands (full list)
    • Convert a P12/PFX Certificate to a .CER
    • How to embed in HTML
    • Misc. Windows Information
    • Issues with missing icons in Windows
    • Information on ‘scoop’ package manager for Windows
    • DISMTools Docs
    • Creating Python Virtual Environment in Windows and Linux
    • Using XnConvert to bulk convert image sizes
    • How to Merge Multiple Text Files using different methods in Windows
    • How to use OLLAMA_ORIGINS in Windows
    • To permanently turn off Windows Security and Windows Defender1
    • Enabling the disabled sounds in Windows
    • Enable classic right-click context menu on Windows 11
    • How to Convert Kindle Books (.awz/.awz3) to Other E-book Formats
    • How to Create Symbolic Links with mklink
    • APIMyLlama Commands
  • 🏬[Graphic] Design
    • Create a Realistic Shadow for Objects in GIMP (video)
    • How to Add Outer Glow Effects in GIMP
    • How to Curve Text In GIMP
    • Rounded corners in GIMP (video)
    • WORD CLOUD TEXT PORTRAIT EFFECT IN PHOTOSHOP (video)
    • BROKEN 3D TEXT EFFECT | PHOTOSHOP (video)
    • Type on a path in Photoshop
    • Nudify Guide (Stable Diffusion)
  • 💻Coding & Developing
    • APIMyLlama V2
      • APIMyLlama Source: Github
    • Insert Back button on a webpage
    • How to have a web page refresh automatically
    • AstroPaper Blog Theme
      • How to configure AstroPaper theme - Blog
      • Adding new posts in AstroPaper theme
    • How to generate Django SECRET_KEY
  • 📒Everything else
    • RSS Feed in your Notion Pages
    • 12 Firefox Hidden Settings You Should Check Out
    • ADB (almost) Full Commands List
    • How to pair your Wear OS smartwatch with a new phone
    • How to reset Cync by GE smart lights
    • IRC Servers & Channels Info
    • Internxt CLI commands and usage
    • Call Forwarding on mobile device
    • Obsidian Templater plugin
    • Exportify Documentation
    • KLLOQUE K10 B Ball Lock User Manual
    • How to delete bloatware from Android device
Powered by GitBook
On this page
  1. Linux OS

Concatenate mp4 files using FFmpeg

Let’s start with the simplest use case which is to concatenate two mp4 files using FFmpeg. Let’s say you have two files file1.mp4 and file2.mp4.You can concatenate these files using the concat demuxer (documentation) easily if their properties match. That is, they have the same height, width, pixel formats, codecs, etc.There are two steps to using this command. First, you need to create a txt file with the names and paths of all the individual files that you want to concatenate. Then, you need to supply this list to FFmpeg as a commandline parameter.Let’s create the list first. Here is an example and let us call the list fileList.txt. In this example, both the files are in the home directory. each line starts with the keyword file and contains the path of the file within single quotes.

$ cat fileList.txt
file '/home/file1.mp4'
file '/home/file1.mp4'

Now, you can concatenate them using the following FFmpeg command./ffmpeg -f concat -safe 0 -i fileList.txt -c copy mergedVideo.mp4Here, you are using the concat command to read the list of video files that you created (fileList.txt) and copy the individual files in that order into an output file called mergedVideo.mp4. Remember, you are not re-encoding in this commandline because you are using the copy command.Concatenate all files in a directoryThis is a commonly asked question and it has to do more with shell scripting than actual FFmpeg usage. The first step you need to do here is to find all the mp4/avi/wav files in your directory and add them to a file. Then you can easily concatenate them as shown above.for f in *.mp4 ; do echo file \\'$f\\' >> fileList.txt;I ran this command in my video database folder and here is the output – looks good right?

file 'brooklynsfinest_clip_1080p.mp4'
file 'parkjoy_1080p50_crf1.mp4'
file 'riverbed_1080p25_crf1.mp4'
file 'simpsons_1080p2398_clip.mp4'
file 'simpsons_trailer.mp4'
file 'touchdown_pass_1080p.mp4'
file 'touchdown_pass_1080p_2997fps.mp4'

And, then you can concatenate them using the concat command we learned about earlier as follows../ffmpeg -f concat -safe 0 -i fileList.txt -c copy mergedVideo.mp4

PreviousHow to Install/Reinstall Linux GRUB MenuNextCommand to stop mirroring screens

Last updated 7 months ago

🖥️