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

A Lot of Technological 'Progress' Has Been Nothing But Buzzwords
Free software does not try to excite people people over nothing
Proprietary Software: Here Today, Gone Tomorrow
Proprietary software has an entirely different mindset, revolving around business models rather than science
Web Hostnames Down to Lowest Number in More Than 7 Years!
the number of hostnames is falling rapidly (they hide this by choosing logarithmic scale)
Over at Tux Machines...
2 days' worth
Stop Begging Companies That Don't Value Your Freedom to Stop Pushing You Around
That's not freedom
The forbidden topics
There are forbidden topics in the hacker community
 
Richard Stallman Gave a Talk Yesterday, Will Give Another Talk Today, and Will Give Two More Talks in Germany Later This Week
Those cover at least 2 different topics
Beware the Microsoft Sharks
We won't forgive and forget
IRC Proceedings: Saturday, September 30, 2023
IRC logs for Saturday, September 30, 2023
Don't be Afraid of the Command Line, It Might Even be a Friend
There's a tendency to think that only graphical interfaces were made to simplify usage, and any declarative interface is by design raw, inherently unfit for usage
One Positive Note About GNU/Linux Coverage in 2023 (Less Microsoft)
GNU/Linux users do not want this, with very rare exceptions
Snaps Were Never Good at Security, But the Media Coverage is Just Appalling
The media should focus on culling Windows, not making a huge fuss over minor things wrongly attributed to "Linux"
Better Footage of Richard Stallman's Talk Last Week: “Freedom in computing, forty years after starting to really protect it”
Richard Stallman speaks about the cancer situation early in his speech
Links 30/09/2023: A Government Shutdown and More Blizzard Layoffs
Links for the day
Links 30/09/2023: Bing Almost Offloaded Due to Failure/Losses, Nvidia Raided
Links for the day
Community is the Lifeblood of Freedom in the GNU/Linux World
Removing or undoing the "cancerd" (systemd) is feasible but increasingly difficult
Richard Stallman Says He Will Probably Live Many More Years
"Richard Stallman has cancer. Fortunately it is slow-growing and manageable follicular lymphona, so he will probably live many more years nonetheless. But he now has to be even more careful not to catch Covid-19."
Quitting 'Clown Computing' and GAFAM is Only the Start
The Web and the Net at large became far too centralised
They Say Free Software is Like Communism When They, the Proprietary Software Giants, Constantly Pursue Government Bailouts (Subsidies From Taxpayers)
At the moment Ukraine is at most risk due to its dependence on Microsoft (inside its infrastructure)
Social Control Media Has No Future, It Was Always Doomed to Fail (Also Promoted Based on Lies)
Recent events, including developments at Twitter, meant that they lost a lot of their audience and then, in turn, sponsors/advertisers
They're Been Trying to 'Kill' Richard Stallman for Years (by Mentally Tormenting Him)
Malicious tongue wanted to do him what had been done to Julian Assange
We Temporarily Have Two Gemini Capsules
They're both authentic and secure, but they're not the same
Consumerism is Lying and Revisionism
We need to reject these liars and charlatans
Links 30/09/2023: Open VFS Framework, CrossOver 23.5, Dianne Feinstein Dies
Links for the day
Security Leftovers
GNU/Linux, Microsoft, and more
Microsoft Down on the World Wide Web, Shows Survey
down by a lot in this category
IRC Proceedings: Friday, September 29, 2023
IRC logs for Friday, September 29, 2023
A Society That Fails Journalists Does Not Deserve Journalism
It's probably too later to save Julian Assange as a working publisher (he might never recover from the mental torture), but as a person and a father we can wish and work towards his release
Almost Nothing To Go With Your Morning's Cup Of Coffee
Newspaper? What newspaper?
Techrights Was Right About the Chaff Bots (They Failed to Live up to Their Promise)
Those who have been paying attention to news of substance rather than fashionable "tech trends" probably know that GNU/Linux grew a lot this year
Selling Out to Microsoft Makes You Dead Beef
If all goes as well as we've envisioned, Microsoft will get smaller and smaller
Curation and Preservation Work
The winter is coming soon and this means our anniversary is near
Mobile Phones Aren't Your Friend or a Gateway to Truly Social Life
Newer should not always seem more seductive, as novelty is by default questionable and debatable
Links 29/09/2023: Disinformation and Monopolies
Links for the day
iFixit Requests DMCA Exemption…To Figure Out How To Repair McDonald’s Ice Cream Machines
Reprinted with permission from Ryan Farmer
Jim Zemlin Thinks the World's Largest Software Company Has 200 Staff, Many of Whom Not Technical at All
biggest ego in the world
Microsoft GitHub Exposé — In the Alex Graveley Case, His Lawyer, Rick Cofer, Appears to Have Bribed the DA to Keep Graveley (and Others) Out of Prison
Is this how one gets out of prison? Hire the person who bribes the DA?
Richard Stallman's Public Talk in GNU's 40th Anniversary Ceremony
Out now
Links 29/09/2023: Linux Foundation Boasting, QLite FDW 2.4.0 Released
Links for the day
Red Hat Does Not Understand Community and It's Publicly Promoting Microsoft's Gartner
RedHat.com is basically lioning a firm that has long been attacking GNU/Linux in the private and public sectors at the behest of Microsoft
A 'Code of Conduct' Typically Promoted by Criminal Corporations to Protect Crimes From Scrutiny
We saw this in action last week
Objections to binutils CoC
LXO response to proposed Code of Conduct
Conde Nast (Reddit), Which Endlessly Defamed Richard Stallman and Had Paid Salaries to Microsoft-Connected Pedophiles, Says You Must Be Over 18 to See 'Stallman Was Right'
Does this get in the way of their Bill Gates-sponsored "Bill Gates says" programme/schedule?
Techrights Extends Wishes of Good Health to Richard M. Stallman
Richard Stallman has cancer
endsoftwarepatents.org Still Going, Some Good News From Canada
a blow to software patents in Canada
The Debian Project Leader said the main thing Debian lacked was more contributors
The Debian Project Leader said the main thing Debian lacked was more contributors
IRC Proceedings: Thursday, September 28, 2023
IRC logs for Thursday, September 28, 2023
Links 28/09/2023: Openwashing and Patent Spam as 'News'
Links for the day