Skip to content

Instantly share code, notes, and snippets.

@ruario
Last active September 17, 2024 01:50
Show Gist options
  • Save ruario/bec42d156d30affef655 to your computer and use it in GitHub Desktop.
Save ruario/bec42d156d30affef655 to your computer and use it in GitHub Desktop.
How to enable HTML5 MP4 (H.264/AAC) video in Vivaldi for Linux, via an alternative FFMpeg library
@powerman
Copy link

May worth to change this line to:

LOUD_DL="wget --config=/dev/null"

in case someone has dir_prefix = ~/download/ in ~/.wgetrc.

@ruario
Copy link
Author

ruario commented Dec 7, 2017

I am a little bit uncomfortable with doing that @powerman as they might have other options in their ~/.wgetrc that they would be suprised to have ignored (e.g. logging). The types of people who make these changes are likely to be the ones who could debug such a problem. You are the first person ever to mention such an issue on any one of my scripts and indeed, you have the solution, which kind of proves the point I feel. ;)

@ruario
Copy link
Author

ruario commented Dec 19, 2017

I added ARM support to the latest-proprietary-media.sh script

@danielfreittas
Copy link

I just runed the sh file.
Works on opensuse Tumbleweed. Thank you.

@u-38
Copy link

u-38 commented Feb 2, 2018

Thank you. Well done.

@blackjackshellac
Copy link

Any chance you can add a username to the path for STAGINGDIR? With multiple system users I have to manually wipe that directory before I can run the script for another user, something like this,

$ diff -u latest-proprietary-media.sh latest-proprietary-media.new.sh 
--- latest-proprietary-media.sh	2018-02-12 09:43:17.654358020 -0500
+++ latest-proprietary-media.new.sh	2018-02-12 09:43:12.829289893 -0500
@@ -37,7 +37,7 @@
 TMP=${TMP:-/tmp}
 
 # Set staging dir
-STAGINGDIR=$TMP/$LOGNAME/chromium-codecs-ffmpeg-extra-staging
+STAGINGDIR=$TMP/chromium-codecs-ffmpeg-extra-staging
 
 # Setup Arch
 case $(uname -m) in

@chewi
Copy link

chewi commented Mar 8, 2018

I should have mentioned this a while back but the Arch method of building your own libffmpeg.so is really slow, overcomplicated, and requires downloading the huge Chromium source tarball. Everything you need is in the FFmpeg sources, you just have to build it in a certain way. I wrote a patch for this, which was rejected by FFmpeg upstream, but we use it in Gentoo. Include the new Makefile in the top-level Makefile and do this:

./configure --disable-shared --enable-static --enable-pic --extra-cflags="-DFF_API_CONVERGENCE_DURATION=0"
make libffmpeg
sudo make install-libffmpeg

@ruario
Copy link
Author

ruario commented Apr 27, 2018

@blackjackshellac why don't you just define $TMP to be somewhere else locally?

@ruario
Copy link
Author

ruario commented Apr 27, 2018

@chewi I will investigate, thanks

@feilee
Copy link

feilee commented Apr 30, 2018

@chewi, i am a gentoo user and i tryed to use the generated libffmpeg.so with ffmpeg sources but the current vivaldi-snapshot does not detect the generated lib. And if i force the library, replacing the original in vivaldi-snapshot, it just broke the video reproduction.

@ruario
Copy link
Author

ruario commented May 2, 2018

@feilee Thanks for confirmation. I was just about to try myself. This makes sense to me as ffmpeg within Chromium is heavily patched, i.e. AFAIK this could not be a true statement

Everything you need is in the FFmpeg sources

So I was suprised anyone claimed it worked

@tarzan73
Copy link

The script works with fedora 28 too. Thanks!

@fiddybux
Copy link

Just a quick thanks for the script...been banging my head on the wall with this one trying everything else I can think of. Works like a charm in bunsenlabs with vivaldi stable.

@mattst
Copy link

mattst commented Oct 16, 2018

ATTN: Linux Mint 17 64 (Qiana, based on Ubuntu 14.04) users:

I downloaded chromium-codecs-ffmpeg-extra_69.0.3497.81-0ubuntu0.16.04.1_amd64.deb, clearly this is the chromium-codecs-ffmpeg-extra file for Ubuntu 16.04.

wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_69.0.3497.81-0ubuntu0.16.04.1_amd64.deb

I manually extracted the libffmpeg.so file from the .deb file (using Archive Manager) and placed it in: /home/USER_DIR/.local/lib/vivaldi/libffmpeg.so

After restarting Vivaldi all videos played perfectly.

@crocket
Copy link

crocket commented Oct 23, 2018

I wrote a patch for this, which was rejected by FFmpeg upstream, but we use it in Gentoo. Include the new Makefile in the top-level Makefile and do this:

The patch doesn't work. https://bugs.gentoo.org/653448

@phd21
Copy link

phd21 commented May 17, 2019

Hi Everyone,

I just installed Vivaldi into my Linux KDE Neon user edition based on Ubuntu 18.04 Bionic. And I really like it, but I had trouble with x264/mp4 videos on the test page? After reading this thread, I checked to see if "chromium-codecs-ffmpeg-extra" was installed in "Synaptic Package Manager (SPM)" and it was installed version 75. I also ran vivaldi from the console terminal prompt which recommended installing an older version.

No suitable library for HTML5 proprietary media (MP4[H.264/AAC]) was found,
therefore only open codecs will play.

To add support for proprietary media, issue the following command and restart
Vivaldi:

curl https://launchpadlibrarian.net/414953672/chromium-codecs-ffmpeg-extra_73.0.3683.75-0ubuntu0.16.04.1_amd64.deb |\
tail -c+1077 | tar JxC ~ --wildcards \*libffmpeg.so --xform 's,.*/,.local/lib/vivaldi/,'

I thought I would just try copying the "libffmpeg.so" from "/usr/lib/chromium-browser/" into the Vivaldi "lib" folder which in my Linux KDE Neon is "/opt/vivaldi/lib/" and restarted Vivaldi and it works great; only vivaldi when run from the console terminal still show I need to install it?
This is the command I used to copy "libffmpeg.so" from the installed "chromium-codecs-ffmpeg-extra" package into Vivaldi's lib folder.
sudo cp -v /usr/lib/chromium-browser/libffmpeg.so /opt/vivaldi/lib/

Hope this helps ...

@victorpydev
Copy link

For my debian system tracking the testing distribution, the easiest of all to run h264 videos on vivaldi was to add a ubuntu repository and a preferences file to exclude all ubuntu packages other than chrome-ffmpeg-codecs-extra. This will also allow new versions of chromium-ffmpeg-codecs-extra to be found and installed in the normal manner used for all other packages.

/etc/apt/sources.list: added an ubuntu repository:

chrome-ffmpeg-extra-codecs from ubuntu to play H264 videos:

deb http://archive.ubuntu.com/ubuntu devel-proposed universe

/etc/apt/preferences.d: added a preference file to exclude all of ubuntu except for chrome-ffmpeg-codecs-extra:
Explanation: block all ubuntu packages
Package: *
Pin: origin "archive.ubuntu.com"
Pin-Priority: -1

Explanation: do not block ffmpeg-extra but lower priority than debian
Package: chromium-codecs-ffmpeg-extra
Pin: origin "archive.ubuntu.com"
Pin-Priority: 476

After installing chrome-ffmpeg-codecs-extra, videos from the test page http://www.quirksmode.org/html5/tests/video.html as well as videos from movies.yahoo.com, netflix and amazon all run well!

=> apt-cache policy chromium-codecs-ffmpeg-extra
chromium-codecs-ffmpeg-extra:
Installed: 55.0.2883.87-0ubuntu2.1328
Candidate: 55.0.2883.87-0ubuntu2.1328
Version table:
*** 55.0.2883.87-0ubuntu2.1328 476
-1 http://archive.ubuntu.com/ubuntu devel-proposed/universe i386 Packages
100 /var/lib/dpkg/status
55.0.2883.87-0ubuntu1.16.10.1330 400 ## package downloaded by the script and kept in local repository ##
400 copy:/usr3/Installs/DEB ./ Packages

<OBRIGADO procurei muito por isto -----> http://www.quirksmode.org/html5/tests/video.html

@ruario
Copy link
Author

ruario commented Aug 28, 2019

It's cool but I am not sure it is the easiest. Just start Vivaldi from a terminal and it gives you a one line command to enable H.264 and AAC

https://help.vivaldi.com/article/html5-proprietary-media-on-linux/#example

@ruario
Copy link
Author

ruario commented Aug 28, 2019

Oh and that quirksmode page is not maintained and does not work

Test cases have been removed at the request of my ISP; they were taking up WAY too much bandwidth.

The Vivaldi help page has it's own test video though

@DanMan
Copy link

DanMan commented Jun 12, 2020

On Fedora 32 you only need to install the GStreamer h.264 package which you can do from Gnome Software. I just did that. Videos work now.

@ruario
Copy link
Author

ruario commented Jun 12, 2020

@DanMan No that is incorrect. Vivaldi will not make use of that package. Vivaldi will fetch the files it needs itself and this document and steps are no longer relevant or valid.

@yenaras
Copy link

yenaras commented Oct 26, 2021

for kde neon, all I had to do was
sudo apt install ubuntu-restricted-extras

@ruario
Copy link
Author

ruario commented Oct 26, 2021

@brandon82890 Nope. That does absolutely nothing for Vivaldi whatsoever.

@yenaras
Copy link

yenaras commented Oct 26, 2021

If you say think so, but it worked for me. It installs the mp4 codecs and also the chromium-codecs-ffmpeg-extra.

https://packages.ubuntu.com/bionic/ubuntu-restricted-addons
https://en.wikipedia.org/wiki/Ubuntu-restricted-extras

@ruario
Copy link
Author

ruario commented Oct 26, 2021

@brandon82890 I am a Vivaldi employee and the person who wrote the code that Vivaldi uses to decide which lib to load to support more codecs. I am telling you that you are completely wrong. Sorry to be blunt.

Why am I so blunt? Because I do not want to sow more confusion amongst other users who might see your message and think this is a solution. It is not.

Vivaldi corrects the situation itself. On install (or startup if that fails) Vivaldi fetches a package in the background and installs a file from it to handle a wider variety of codecs. It will not look at any of the libraries in the packages you listed. Most likely you believe you fixed it because on first start the support file had not yet been fetched by Vivaldi. Vivaldi then initiated the process to fix the situation. You then installed what you thought was a package that would fix the situation. This had no effect at all but on restart, the file Vivaldi fetched was then used. Remove ubuntu-restricted-extras and associated dependencies and you will find that Vivaldi still works.

@yenaras
Copy link

yenaras commented Oct 26, 2021

Oh wow, you're right, I did sudo apt remove ubuntu-restricted* and then restarted the browser. It still works fine. Sorry for the misinformation. It must have been a coincidence like you said.

@MDAR
Copy link

MDAR commented Jul 28, 2022

@ruario

Vivaldi corrects the situation itself. On install (or startup if that fails) Vivaldi fetches a package in the background and installs a file from it to handle a wider variety of codecs. It will not look at any of the libraries in the packages you listed. Most likely you believe you fixed it because on first start the support file had not yet been fetched by Vivaldi. Vivaldi then initiated the process to fix the situation. You then installed what you thought was a package that would fix the situation. This had no effect at all but on restart, the file Vivaldi fetched was then used. Remove ubuntu-restricted-extras and associated dependencies and you will find that Vivaldi still works.

Would you be kind enough to ask your team to look into why Vivaldi on DietPi V8.7 (Debian based) on an Odroid C4 doesn't load the required files in order to play H.264 videos?

I have restarted the app a number of times and still get the same message.

Re - MichaIng/DietPi#5300

I have had to look for an alternative to Chromium because we just can't get it to run in a kiosk mode in an Xinit session any more.
Something upstream has been changed and now all we get is "Stack Smashing"

Vivaldi loaded and ran perfectly without any issues, other than the H.264 playback.

I'm happy to try anything your team suggests.

@ruario
Copy link
Author

ruario commented Aug 1, 2022

@MDAR I know why H.264 is failing for you and hope to get out a fix soon. In the mean time I can give you a work around.

If it is armhf

wget -O- https://launchpadlibrarian.net/614082413/chromium-codecs-ffmpeg-extra_103.0.5060.134-0ubuntu0.18.04.1_armhf.deb | tail -c+1157 | tar xOJ ./usr/lib/chromium-browser/libffmpeg.so > libffmpeg.so.5.3
sudo install -m755 libffmpeg.so.5.3 /opt/vivaldi/libffmpeg.so.5.3

If it is arm64

wget -O- https://launchpadlibrarian.net/614041844/chromium-codecs-ffmpeg-extra_103.0.5060.134-0ubuntu0.18.04.1_arm64.deb | tail -c+1157 | tar xOJ ./usr/lib/chromium-browser/libffmpeg.so > libffmpeg.so.5.3
sudo install -m755 libffmpeg.so.5.3 /opt/vivaldi/libffmpeg.so.5.3

@MDAR
Copy link

MDAR commented Aug 1, 2022

Thanks @ruario

wget -O- https://launchpadlibrarian.net/614041844/chromium-codecs-ffmpeg-extra_103.0.5060.134-0ubuntu0.18.04.1_arm64.deb | tail -c+1157 | tar xOJ ./usr/lib/chromium-browser/libffmpeg.so > libffmpeg.so.5.3
sudo install -m755 libffmpeg.so.5.3 /opt/vivaldi/libffmpeg.so.5.3

That certainly works with an Odroid C4 to get the video to load and be manually played.

In chromium, there is a setting I need to adjust in order for it to AutoPlay.

Settings
Privacy
Sound = Allow

I have checked that this setting is ON in Vivaldi, but the video won't autoplay, if a websocket command is received to load and play a video.

Videos will play if I click on the Play button (as per your test page)

I'm very happy to open a port so you can access the machine I am generating the content with.

FYI
I'm trying to get this working, with Vivadli instead of Chromium
https://youtu.be/FinliWWOBOU?t=157

Best wishes,
Stuart

@MDAR
Copy link

MDAR commented Aug 1, 2022

@ruario

Small update.

If I start the browser in kiosk mode, it will display the video, but NOT play it.

Until

I press F11 Twice

After that, it behaves perfectly.

The only issue is that I can't automate that button press

Have you any ideas on how I can get around this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment