Bonum Certa Men Certa

Self-Hosting Videos With Free Formats and Animated Previews, Watermarks/Logos and Translucency

Summary: We examine the power of video editing with ffmpeg, chained with command-line scripting and HTML5 features

The Web is a powerful platform -- to the point where it's a little 'too' powerful if put in the hands of malicious actors. But we're still using the Web by default; it's just what most people use. Video functionality on the Web improved a lot over the years, putting aside DRM/EME. So let's explore what we can accomplish with some command-line scripting and ffmpeg.



We're always trying to encourage digital autonomy, which is why we adopt self-hosting whenever possible. This includes videos. For the sake of example, in this post we use an old video about Gemini proxies. It was picked at random, no special reason at all. None.

Extracting bits of the video with ffmpeg isn't hard (check the official ffmpeg Web site; their documentation explains the pertinent options, which should be changed depending on the video):

ffmpeg -ss 600 -t 5 -i gemini-proxies.webm -vf "select=not(mod(n\,1)),fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 roy-talks.gif

This gets us started:



To add the resultant preview (known as "poster") to the video, consider using the following, based on the above example: poster="http://techrights.org/wp-content/uploads/2021/04/roy-talks.gif"

This attribute belongs in the <video> element as it is part of the standard.

Add the watermark/logo with ffmpeg:

ffmpeg -i roy-talks.gif -i mogz-video-poster-4-small.png -filter_complex "overlay=0:H-h--1" -codec:a copy roy-talks2.gif

We use artwork prepared by Mogz for us.

These two passes may be lossy and maybe possible to combine rather easily, but splitting it into two stages aids simplicity. Here it goes:



For center: overlay=(W-w)/2:(H-h)/2 Top left (with 5 pixels of padding): overlay=5:5 Top right: overlay=W-w-5:5 Bottom right: overlay=W-w-5:H-h-5 Bottom left: overlay=5:H-h-5

With improved quality and translucency:

ffmpeg -i roy-talks.gif -i mogz-video-poster-4-small.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.7[logo];[0][logo]overlay=0:H-h--1:format=auto" -codec:a copy roy-talks2.gif



The above scripts are possible to chain together and variables can be used, too. Let's change the time to one minute from the start (-ss 60) for a duration of 2 seconds (-t 2):

VIDEO_FILE='gemini-proxies' ffmpeg -ss 60 -t 2 -i $VIDEO_FILE.webm -vf "select=not(mod(n\,1)),fps=10,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" -loop 0 intermediate.gif ffmpeg -i intermediate.gif -i mogz-video-poster-4-small.png -filter_complex "[1]format=rgba,colorchannelmixer=aa=0.7[logo];[0][logo]overlay=0:H-h--1:format=auto" -codec:a copy $VIDEO_FILE.gif

Of course it is also possible to use loops and batch-process many files in this way. Welcome to the power of GNU/Linux.



Voila. The translucency is easier to see because of the mug of coffee.

Recent Techrights' Posts

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
 
Running This Site Mostly a Joyful Activity
The real problem or the thing that we need to cancel is this "Cancel Culture"
Australia Has Finally Joined the "4% Club" (ChromeOS+GNU/Linux)
statCounter stats
Debian as a Hazardous Workplace Where No Accountability Exists (Nor Salaries)
systematic exploitation of skilled developers by free 'riders' (or freeloaders) like Google, IBM, and Microsoft
Clownflare Isn't Free and Its CEO Openly Boasted They'd Start Charging Everyone to Offset the Considerable Losses (It's a Trap, It's Just Bait)
Clownflare has collapsed
Apple Delivered Very Disappointing Results, Said It Would Buy Its Own Shares (Nobody Will Check This), Company's Debt Now Exceeds Its Monetary Assets
US debt is now 99.98 trillion dollars
FSFE Still Boasts About Working Underage People for No Pay
without even paying them
IRC Proceedings: Saturday, May 04, 2024
IRC logs for Saturday, May 04, 2024
Over at Tux Machines...
GNU/Linux news for the past day
The Persecution of Richard Stallman
WebM version of a new video
Molly de Blanc has been terminated, Magdalen Berns' knockout punch and the Wizard of Oz
Reprinted with permission from disguised.work
[Meme] IBM's Idea of Sharing (to IBM)
the so-called founder of IBM worshiped and saluted Adolf Hitler himself
Neil McGovern & Debian: GNOME and Mollygate
Reprinted with permission from disguised.work
[Meme] People Who Don't Write Code Demanding the Removal of Those Who Do
She has blue hair and she sleeps with the Debian Project Leader
Jaminy Prabaharan & Debian: the GSoC admin who failed GSoC
Reprinted with permission from disguised.work
Jonathan Carter, Matthew Miller & Debian, Fedora: Community, Cult, Fraud
Reprinted with permission from disguised.work
Techrights This May
We strive to keep it lean and fast
Links 04/05/2024: Attacks on Workers and the Press
Links for the day
Gemini Links 04/05/2024: Abstractions in Development Considered Harmful
Links for the day
Links 04/05/2024: Tesla a "Tech-Bubble", YouTube Ads When Pausing
Links for the day
[Meme] The Cancer Culture
Mission accomplished?
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
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'
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"...
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
Who really owns Debian: Ubuntu or Google?
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