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

Why the Articles From Daniel Pocock (FSFE, Fedora, Debian Etc. Insider) Still Matter a Lot
Revisionism will try to suggest that "it's not true" or "not true anymore" or "it's old anyway"...
Who really owns Debian: Ubuntu or Google?
Reprinted with permission from disguised.work
 
Germany Transitioning to GNU/Linux
Why aren't more German federal states following the footsteps of Schleswig-Holstein?
IRC Proceedings: Friday, May 03, 2024
IRC logs for Friday, May 03, 2024
Over at Tux Machines...
GNU/Linux news for the past day
Alexander Wirt, Bucha executions & Debian political prisoners
Reprinted with permission from disguised.work
Free Software Community/Volunteers Aren't Circus Animals of GAFAM, IBM, Canonical and So On...
Playing with people's lives for capital gain or "entertainment" isn't acceptable
Links 03/05/2024: Clownflare Collapses and China Deploys Homegrown Aircraft Carrier
Links for the day
IBM's Decision to Acquire HashiCorp is Bad News for Red Hat
IBM acquired functionality that it had already acquired before
Apparently Mass Layoffs at Microsoft Again (Late Friday), Meaning Mass Layoffs Every Month This Year Including May
not familiar with the source site though
Gemini Links 03/05/2024: Diaspora Still Alive and Fight Against Fake News
Links for the day
[Meme] Reserving Scorn for Those Who Expose the Misconduct
they like to frame truth-tellers as 'harassers'
Links 03/05/2024: Canada Euthanising Its Poor and Disabled, Call for Julian Assange's Freedom
Links for the day
Dashamir Hoxha & Debian harassment
Reprinted with permission from disguised.work
Maria Glukhova, Dmitry Bogatov & Debian Russia, Google, debian-private leaks
Reprinted with permission from disguised.work
Keeping Computers at the Hands of Their Owners
There's a reason why this site's name (or introduction) does not obsess over trademarks and such
In May 2024 (So Far) statCounter's Measure of Linux 'Market Share' is Back at 7% (ChromeOS Included)
for several months in a row ChromeOS (that would be Chromebooks) is growing
Links 03/05/2024: Microsoft Shutting Down Xbox 360 Store and the 360 Marketplace
Links for the day
Evidence: Ireland, European Parliament 2024 election interference, fake news, Wikipedia, Google, WIPO, FSFE & Debian
Reprinted with permission from Daniel Pocock
Enforcing the Debian Social Contract with Uncensored.Deb.Ian.Community
Reprinted with permission from Daniel Pocock
Gemini Links 03/05/2024: Antenna Needs Your Gemlog, a Look at Gemini Get
Links for the day
IRC Proceedings: Thursday, May 02, 2024
IRC logs for Thursday, May 02, 2024
Over at Tux Machines...
GNU/Linux news for the past day
Jonathan Carter & Debian: fascism hiding in broad daylight
Reprinted with permission from disguised.work
Gunnar Wolf & Debian: fascism, anti-semitism and crucifixion
Reprinted with permission from disguised.work
Links 01/05/2024: Take-Two Interactive Layoffs and Post Office (Horizon System, Proprietary) Scandal Not Over
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Wednesday, May 01, 2024
IRC logs for Wednesday, May 01, 2024
Embrace, Extend, Replace the Original (Or Just Hijack the Word 'Sudo')
First comment? A Microsoft employee
Gemini Links 02/05/2024: Firewall Rules Etiquette and Self Host All The Things
Links for the day