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

Microsoft: Our "Goodwill" Gained Over 51 Billion Dollars in the Past Nine Months Alone, Now "Worth" as Much as All Our Physical Assets (Property and Equipment)
The makeup of a Ponzi scheme where the balance sheet has immaterial nonsense
FSFE (Ja, Das Gulag Deutschland) Has Lost Its Tongue
Articles/month
Ian Jackson & Debian reject mediation
Reprinted with permission from disguised.work
How to get selected for Outreachy internships
Reprinted with permission from disguised.work
 
Lucas Kanashiro & Debian/Canonical/Ubuntu female GSoC intern relationship
Reprinted with permission from disguised.work
Pranav Jain & Debian, DebConf, unfair rent boy rumors
Reprinted with permission from disguised.work
Links 27/04/2024: Kaiser Gave Patients' Data to Microsoft, "Microsoft Lost ‘Dream Job’ Status"
Links for the day
Gemini Links 27/04/2024: Sunrise Photos and Slow Productivity
Links for the day
Almost 2,700 New Posts Since Upgrading to Static Site 7 Months Ago, Still Getting More Productive Over Time
We've come a long way since last autumn
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Friday, April 26, 2024
IRC logs for Friday, April 26, 2024
Overpaid lawyer & Debian miss WIPO deadline
Reprinted with permission from disguised.work
Brian Gupta & Debian: WIPO claim botched, suspended
Reprinted with permission from disguised.work
Microsoft's XBox is Dying (For Second Year in a Row Over 30% Drop in Hardware Sales)
they boast about fake numbers or very deliberately misleading numbers that represent two companies, not one
[Meme] Granting a Million Monopolies in Europe (to Non-European Companies) at Europe's Expense
Financialization of the EPO
Salary Adjustment Procedure at the EPO Challenged
the EPO must properly compensate staff in order to attract and retain suitably skilled examiners
Links 26/04/2024: Surveillance Abundant, Restoring Net Neutrality Rules (US)
Links for the day
Gemini Links 26/04/2024: uConsole and EXWM and stdu 1.0.0
Links for the day
Red Hat Corporate Communications is "Red" Now
Also notice they offer just two options: MICROSOFT or... MICROSOFT!
Links 26/04/2024: XBox Sales Have Collapsed, Facebook's Shares Collapse Too
Links for the day
Albanian women, Brazilian women & Debian Outreachy racism under Chris Lamb
Reprinted with permission from disguised.work
Microsoft-Funded 'News' Site: XBox Hardware Revenue Declined by 31%
Ignore the ludicrous media spin
Mark Shuttleworth, Elio Qoshi & Debian/Ubuntu underage girls
Reprinted with permission from disguised.work
Karen Sandler, Outreachy & Debian Money in Albania
Reprinted with permission from disguised.work
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Thursday, April 25, 2024
IRC logs for Thursday, April 25, 2024
Links 26/04/2024: Facebook Collapses, Kangaroo Courts for Patents, BlizzCon Canceled Under Microsoft
Links for the day
Gemini Links 26/04/2024: Music, Philosophy, and Socialising
Links for the day
Microsoft Claims "Goodwill" Is an Asset Valued at $119,163,000,000, Cash Decreased From $34,704,000,000 to $19,634,000,000 and Total Liabilities Grew to $231,123,000,000
Earnings Release FY24 Q3
More Microsoft Cuts: Events Canceled, Real Sales Down Sharply
So they will call (or rebrand) everything "AI" or "Azure" or "cloud" while adding revenues from Blizzard to pretend something is growing
CISA Has a Microsoft Conflict of Interest Problem (CISA Cannot Achieve Its Goals, It Protects the Worst Culprit)
people from Microsoft "speaking for" "Open Source" and for "security"
Links 25/04/2024: South Korean Military to Ban iPhone, Armenian Remembrance Day
Links for the day
Gemini Links 25/04/2024: SFTP, VoIP, Streaming, Full-Content Web Feeds, and Gemini Thoughts
Links for the day
Audiocasts/Shows: FLOSS Weekly and mintCast
the latest pair of episodes
[Meme] Arvind Krishna's Business Machines
He is harming Red Hat in a number of ways (he doesn't understand it) and Fedora users are running out of patience (many volunteers quit years ago)
[Video] Debian's Newfound Love of Censorship Has Become a Threat to the Entire Internet
SPI/Debian might end up with rotten tomatoes in the face
Joerg (Ganneff) Jaspert, Dalbergschule Fulda & Debian Death threats
Reprinted with permission from disguised.work
Amber Heard, Junior Female Developers & Debian Embezzlement
Reprinted with permission from disguised.work
[Video] Time to Acknowledge Debian Has a Real Problem and This Problem Needs to be Solved
it would make sense to try to resolve conflicts and issues, not exacerbate these
Daniel Pocock elected on ANZAC Day and anniversary of Easter Rising (FSFE Fellowship)
Reprinted with permission from Daniel Pocock
[Video] IBM's Poor Results Reinforce the Idea of Mass Layoffs on the Way (Just Like at Microsoft)
it seems likely Red Hat layoffs are in the making
Ulrike Uhlig & Debian, the $200,000 woman who quit
Reprinted with permission from disguised.work
IRC Proceedings: Wednesday, April 24, 2024
IRC logs for Wednesday, April 24, 2024
Over at Tux Machines...
GNU/Linux news for the past day