Bonum Certa Men Certa

Adding, Seaming Together, Merging, or Concatenating Videos From the Command Line With FFMPEG (Scripting for Streamlining of Workflows)

Video download link



Summary: In order to enrich the looks of videos with almost no extra time/effort (all scripted, no GUIs should be needed) use ffmpeg with the concat operator; but there are several big gotchas, namely lack of sound and need for consistency across formats/codecs and even sampling rates

TODAY we focused on some site 'logistics' and especially dealt with video and sound. The goal is to automate some tasks and/or improve the presentation of multimedia using Free software. Free as in freedom...



Frankly, the tool we used to generate some video segments was an "online" thing called Canva (never heard of it before, but it seems powerful enough and doesn't require downloading anything, logging in etc. -- not even an E-mail address). On the face of it, problem solved! But no... it gets trickier from then on. I spent many hours working around barriers.

Well, ffmpeg is very powerful and extremely versatile. However, as it turns out, ffmpeg will first need to convert .mp4 files downloaded from there (Canva) so as to incorporate sound, even if it's just mute (inaudible sound track).

For this reason and for that purpose, as per people who had similar issues concatenation tracks that lack sound (merged or combined with some that do have sound), run a command as follows (depending on the sampling rate, 48000 in my case, or else the sound/pitch will be funny).

ffmpeg -i "file.mp4" -f lavfi -i anullsrc=cl=mono:r=48000 -shortest -y "file-new.mp4"

Assuming you now have a track that is compatible with what you'd merge it with, ensure that the original is moreover re-encoded for it to be applied consistently. As I always record as WebM, I need to then run (for a video like the above):

ffmpeg -i video-ffmpeg-concat.webm -c:v libx264 -preset slow video-ffmpeg-concat.mp4

This yields something suitable as it must be strictly compatible in sampling, codec type, and other factors. That's a limitation in ffmpeg. This is a common issue for a lot of people and it took me hours to overcome (many trials and errors). I wished to document this as other people too got stuck (many forum posts).

Depending on which files you wish to concatenate with (and the order), write down the 'recipe', e.g. recipe.txt, containing

file file-new.mp4
file testing-6.mp4
file outro-new.mp4


Relative paths too can be prepended (e.g. file Videos/outro-new.mp4). The ffmpeg documentation explains the syntax better. There's a lot more about concat [1, 2].

Then run everything as follows:

ffmpeg -f concat -i recipe.txt output.webm

The reason the assembly of files is done with .mp4 files (to yield a WebM) is the insistence of Canva that downloaded videos are either MP4 or GIF. There must be some better ways and I'll improve this over time (this is all still very fresh in the mind; I've spent a lot of time on this).

From now on we have the ability to make videos that are 1) smaller in size because of re-encoding with strong compression and 2) have a little bit of extra context. We'll improve this over time and push to git.

Update: This is what the outcome can look like (mind start and end of clip).

Video download link

Recent Techrights' Posts

There Are Days or Occasions Where gemini:// Requests Almost Exceed http(s):// and Gemini Protocol Isn't Even 6 Yet
Gemini Protocol turns 6 one month from now
 
Gemini Links 18/05/2025: "Finally Upgraded" and "Rebooting"
Links for the day
Abundance of Good Code, "Just Like Air."
Richard Stallman's seminal manifesto and foundational (practical) work on GNU gave us a very solid system that facilitates productive work without concerns over spyware
Messages in TheLayoff.com Drowned Out by LLM Slop (Comments Focused on Replying to Bot-Generated Provocation)
apparently shaking hands with nazis isn't as bad as calling your git repository's main branch "master"
The Importance of Full Disclosure and Transparency Online
there will be full transparency, as always
Slopwatch: Slopfarms and Serial Sloppers Still at It
Apparently Google is too understaffed to figure that out
Links 18/05/2025: Decreased Prospects of Science Careers, Disappearance of Journalists
Links for the day
Microsofters Have a Long History Trying to Take Down Techrights by Sending Threats to Webhosts
picking on women
Links 18/05/2025: Science, Censorship and European Commission Taking on Monopoly Abuse by Microsoft
Links for the day
Gemini Links 18/05/2025: Šibenik and SFJAZZ Historical Archive
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Saturday, May 17, 2025
IRC logs for Saturday, May 17, 2025
Links 17/05/2025: Microsoft Kills "Surface Laptop Studio" (More Canceled Products/Units), Groups Caution About Harms of Social Control Media
Links for the day
Gemini Links 17/05/2025: Sympathy Algorithm and SSH on Alternative Ports
Links for the day
Inviting the Founder of GNU/Linux to Events (It Only Costs His Travel Expenses) and Recalling the True Origins
It's reassuring to see belated recognition
Slopwatch: Microsoft's Anti-Linux Propaganda and Cover-up, Slopfarms Clogging Up Google News
slop-tracking activities that observe googlebombing of "Linux"
AstroTurfing by IBM in thelayoff.com is Highly Risky (and Likely Outsourced)
Microsoft did this in Reddit (and got caught), so why won't IBM too?
Links 17/05/2025: Stabber of Salman Rushdie Sentenced to 25 Years in Prison
Links for the day
The Microsofters Have Just Shared Privileged Trial Data With Microsoft
There are serious ramifications for liability accountability as Microsoft salaries sponsor these SLAPPs
Trolls With LLM Slop Are Disrupting Communications About Mass Layoffs at IBM
LLM slop to drown out the signal
Gemini Links 17/05/2025: Happier on Gemini and Manipulating Reddit
Links for the day
ComEd and Microsoft: A Mess of Spaghetti Held Together By Circus Clowns
Reprinted with permission from Ryan Farmer
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Friday, May 16, 2025
IRC logs for Friday, May 16, 2025
Links 16/05/2025: Microsoft Sacks Pregnant Women, People Fired on Their Birthday; Adobe Censorship Failing
Links for the day
Gemini Links 16/05/2025: "Repairing Our Way out of Commodity Fetishism" and Pre-librebooted Computers
Links for the day
[Video] IBM Shakes Hands of Prince Mohammed bin Salman
handshake of loyalty
The SLAPPs From Microsofters Distract From Serious Copyright Infringement by Microsoft and Apparent Business Crimes
Aside from other issues, such as strangling women
Enshittification is Everywhere: You Pay More, the Services Get Worse
"Enshittification" is a term coined by an online friend; I increasingly use this term to describe what's happening even outside the realm of technology (which it was adopted to describe)
Microsoft Reduces Office Space Ahead of More Waves of Mass Layoffs
"The Gerstnerisation of Microsoft"
Anti-Linux FUD Produced by Microsoft LLMs to Blame "Linux" for Microsoft's Own Failures
We call out some of the worst culprits
Gemini Links 16/05/2025: Hoking GPS, Grabovac, and Tanana
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Thursday, May 15, 2025
IRC logs for Thursday, May 15, 2025