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

Topics We Lacked Time to Cover
Due to a Microsoft event (an annual malware fest for lobbying and marketing purposes) there was also a lot of Microsoft propaganda
EPO Education: Workers Resort to Legal Actions (Many Cases) Against the Administration
At the moment the casualties of EPO corruption include the EPO's own staff
 
Links 22/11/2024: Dynamic Pricing Practice and Monopoly Abuses
Links for the day
Microsofters Try to Defund the Free Software Foundation (by Attacking Its Founder This Week) and They Tell People to Instead Give Money to Microsoft Front Groups
Microsoft people try to outspend their critics and harass them
[Meme] EPO for the Kids' Future (or Lack of It)
Patents can last two decades and grow with (or catch up with) the kids
Gemini Links 22/11/2024: ChromeOS, Search Engines, Regular Expressions
Links for the day
This Month is the 11th Month of This Year With Mass Layoffs at Microsoft (So Far It's Happening Every Month This Year, More Announced Hours Ago)
Now they even admit it
Links 22/11/2024: Software Patents Squashed, Russia Starts Using ICBMs
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Thursday, November 21, 2024
IRC logs for Thursday, November 21, 2024
Gemini Links 21/11/2024: Alphabetising 400 Books and Giving the Internet up
Links for the day
Links 21/11/2024: TikTok Fighting Bans, Bluesky Failing Users
Links for the day
Links 21/11/2024: SpaceX Repeatedly Failing (Taxpayers Fund Failure), Russian Disinformation Spreading
Links for the day
Richard Stallman Earned Two More Honorary Doctorates Last Month
Two more doctorate degrees
KillerStartups.com is an LLM Spam Site That Sometimes Covers 'Linux' (Spams the Term)
It only serves to distract from real articles
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Wednesday, November 20, 2024
IRC logs for Wednesday, November 20, 2024
Gemini Links 20/11/2024: Game Recommendations, Schizo Language
Links for the day
Growing Older and Signs of the Site's Maturity
The EPO material remains our top priority
Did Microsoft 'Buy' Red Hat Without Paying for It? Does It Tell Canonical What to Do Now?
This is what Linus Torvalds once dubbed a "dick-sucking" competition or contest (alluding to Red Hat's promotion of UEFI 'secure boot')
Links 20/11/2024: Politics, Toolkits, and Gemini Journals
Links for the day
Links 20/11/2024: 'The Open Source Definition' and Further Escalations in Ukraine/Russia Battles
Links for the day
[Meme] Many Old Gemini Capsules Go Offline, But So Do Entire Web Sites
Problems cannot be addressed and resolved if merely talking about these problems isn't allowed
Links 20/11/2024: Standing Desks, Broken Cables, and Journalists Attacked Some More
Links for the day
Links 20/11/2024: Debt Issues and Fentanylware (TikTok) Ban
Links for the day
Jérémy Bobbio (Lunar), Magna Carta and Debian Freedoms: RIP
Reprinted with permission from Daniel Pocock
Jérémy Bobbio (Lunar) & Debian: from Frans Pop to Euthanasia
Reprinted with permission from Daniel Pocock
This Article About "AI-Powered" is Itself LLM-Generated Junk
Trying to meet quotas by making fake 'articles' that are - in effect - based on plagiarism?
Recognizing invalid legal judgments: rogue Debianists sought to deceive one of Europe's most neglected regions, Midlands-North-West
Reprinted with permission from Daniel Pocock
Google-funded group distributed invalid Swiss judgment to deceive Midlands-North-West
Reprinted with permission from Daniel Pocock
Gemini Links 20/11/2024: BeagleBone Black and Suicide Rates in Switzerland
Links for the day
Over at Tux Machines...
GNU/Linux news for the past day
IRC Proceedings: Tuesday, November 19, 2024
IRC logs for Tuesday, November 19, 2024