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

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: Five Years on Gemini and Atom Feeds over Gopher
Links for the day
Links 18/05/2025: F.D.A. More Sceptical of COVID-19 Vaccines, UK Charges 3 Iranian Nationals In Alleged Attack Plot Against Journalists
Links for the day
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