Skip to content

Instantly share code, notes, and snippets.

@ruario
Last active July 25, 2025 07:24
Show Gist options
  • Select an option

  • Save ruario/bec42d156d30affef655 to your computer and use it in GitHub Desktop.

Select an option

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

How to enable HTML5 MP4 (H.264/AAC) video in Vivaldi for Linux, via an alternative FFMpeg library

Intro

The following is a quick guide to get this working on various Linux distros. As a side note, if you have Chrome installed alongside Vivaldi, Netflix should also work after making these changes. Alternatively, use my latest-widevine.sh to fetch and extract Chrome's copy of Widevine, so that it can be used by Vivaldi.

If you don't have working Flash video and need that in addition, please refer to these instructions.

Note: This guide is primarrily aimed at users of Vivaldi stable releases. If it does not solve your issues, read this in addition.

Ubuntu

Install chromium-codecs-ffmpeg-extra

sudo apt update && sudo apt install chromium-codecs-ffmpeg-extra

You will now need to restart Vivaldi. You can then test support on this page.

Arch

Install from the AUR

If you want to use the latest stable, install vivaldi and vivaldi-ffmpeg-codecs.

If you want to use the latest snapshot, install vivaldi-snapshot and vivaldi-snapshot-ffmpeg-codecs.

Install from the unofficial herecura repo

Alternatively, you can also get both of these packages from from the unofficial [herecura] repo.

Note: Do not use the herecura repo, if you use related distros like Chakra and Manjaro. These are not real “Arch Linux” and have differences that are great enough, that you are likely to encounter problems (if not right away, then some time in the future).

After installing from the AUR or the linked unofficial repository, will now need to restart Vivaldi. You can then test support on this page.

Other distros

If your distro does not provide a package with a suitable library or one is not detected, you can run the script ./latest-proprietary-media.sh (included with this gist) as your normal user (not root) to fetch and install the Ubuntu file. Once installed, simply restart Vivaldi. You can then test support on this page.

If you would prefer not use a script, here is a short summary of how to do this manually.

First, have a look in http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ for a “chromium-codecs-ffmpeg-extra” package from a recent Ubuntu version.

Fetch it like so (adjusting the package name as needed):

wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_63.0.3239.84-0ubuntu0.17.10.1_amd64.deb

To Extract out the lib and install it for Vivaldi's usage, enter the following (adjusting the package name as needed):

ar p chromium-codecs-ffmpeg-extra_63.0.3239.84*.deb data.tar.xz | tar Jx ./usr/lib/chromium-browser/libffmpeg.so --strip 4
install -Dm644 libffmpeg.so "$HOME/.local/lib/vivaldi/libffmpeg.so"

Next time you restart Vivaldi it should find this library and use it to decode proprietary media.

Building your own replacement libffmpeg.so

If you want to build your own replacement libffmpeg use the Arch vivaldi-snapshot-ffmpeg-codecs PKGBUILD as a guide.

If you are a maintainer and intend to repackage Vivaldi browser for your distro, you might want to consider making vivaldi-ffmpeg-codecs or vivaldi-snapshot-ffmpeg-codecs packages containing a replacement libffmpeg.so library. It is suggested that you place this library in the directory /opt/vivaldi/ or /opt/vivaldi-snapshot/ directories respectively. You will need to update these packages from time to time as Vivaldi ups its Chromium version.

#!/bin/sh
# Discourage Ubuntu users from using this script, since they can (and should) install chromium-codecs-ffmpeg-extra directly
if [ -r /etc/os-release ] && grep -qx 'ID=ubuntu' /etc/os-release; then
echo "You should not use this script on Ubuntu, install chromium-codecs-ffmpeg-extra via apt instead." >&2
read -p "Do you wish to continue anyway? [y/N]: " YN
case "$YN" in
[Yy]*) : ;;
[Nn]*) echo "Exiting." ; exit ;;
*) echo 'Answer not recognised, assuming "No". Exiting.'; exit ;;
esac
fi
# Make sure the user is not runing as superuser
if [ "$UID" = "0" ]; then
echo 'Do not run this script as root or via sudo. Run it as your normal user.' >&2
exit 1
fi
available () {
command -v $1 >/dev/null 2>&1
}
# Make sure we have wget or curl
if available wget; then
SILENT_DL="wget -qO-"
LOUD_DL="wget"
elif available curl; then
SILENT_DL="curl -sL"
LOUD_DL="curl -O"
else
echo "Install Wget or cURL" >&2
exit 1
fi
# Set temp dir
TMP=${TMP:-/tmp}
# Set staging dir
STAGINGDIR=$TMP/chromium-codecs-ffmpeg-extra-staging
# Setup Arch
case $(uname -m) in
x86_64) ARCH=x86_64; DEB_ARCH=amd64; REPO=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ ;;
i?86) ARCH=i386; DEB_ARCH=i386; REPO=http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ ;;
armhf) ARCH=armhf; DEB_ARCH=armhf; REPO=http://ports.ubuntu.com/ubuntu-ports/pool/universe/c/chromium-browser/ ;;
arm64) ARCH=arm64; DEB_ARCH=arm64; REPO=http://ports.ubuntu.com/ubuntu-ports/pool/universe/c/chromium-browser/ ;;
esac
# Work out the VERSION
UBUNTU_PACKAGE=$(${SILENT_DL} $REPO | sed -rn "s/.*(chromium-codecs-ffmpeg-extra_([0-9]+\.){3}[0-9]+-[0-9]ubuntu[0-9]\.([0-9]{2}\.){2}[0-9\.]*_$DEB_ARCH.deb).*/\1/p" | sort | tail -n 1)
VERSION=$(echo "${UBUNTU_PACKAGE}" | sed -rn "s/.*_(([0-9]+\.){3}[0-9]+)-.*/\1/p")
# Error out if $VERISON is unset, e.g. because previous command failed
if [ -z "$VERSION" ]; then
echo "Could not work out the latest version; exiting" >&2
exit 1
fi
# Don't start repackaging if the same version is already installed
if [ -r "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt" ]; then
. "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt"
if [ "$INSTALLED_VERSION" = "$VERSION" ]; then
echo "The latest chromium-codecs-ffmpeg-extra ($VERSION) is already installed"
exit 0
fi
fi
# Now we could screw things up so exit on first error
set -e
# If the staging directory is already present from the past, clear it down
# and re-create it.
if [ -d "$STAGINGDIR" ]; then
rm -fr "$STAGINGDIR"
fi
mkdir "$STAGINGDIR"
cd "$STAGINGDIR"
# Now get the deb package
$LOUD_DL "$REPO$UBUNTU_PACKAGE"
# Extract the contents of the chromium-codecs-ffmpeg-extra package
if available bsdtar; then
DEB_EXTRACT_COMMAND='bsdtar xOf'
elif available ar; then
DEB_EXTRACT_COMMAND='ar p'
else
echo 'You must install BSD tar or GNU binutils to use this script.' >&2
exit 1
fi
$DEB_EXTRACT_COMMAND ${UBUNTU_PACKAGE} data.tar.xz | tar xJf - ./usr/lib/chromium-browser/libffmpeg.so --strip 4
# Check the libffmpeg.so dependencies are resolved
if LANGUAGE=en ldd libffmpeg.so 2>&1 | grep -qm1 'not \(a dynamic executable\|found\)'; then
cat <<EOF >&2
It is not possible to use this alternative libffmpeg on your system.
Let us know via a post in our forums, mentioning your distro and distro
version:
https://forum.vivaldi.net/category/35/vivaldi-browser-for-linux
EOF
exit 1
fi
# Note the version number for future reference, during upgrades
echo "INSTALLED_VERSION=$VERSION" > chromium-codecs-ffmpeg-extra-version.txt
# Install the files
install -Dm644 libffmpeg.so "$HOME/.local/lib/vivaldi/libffmpeg.so"
install -Dm644 chromium-codecs-ffmpeg-extra-version.txt "$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt"
# Tell the user we are done
cat <<EOF
The following files were installed onto your system:
$HOME/.local/lib/vivaldi/libffmpeg.so
$HOME/.local/lib/vivaldi/chromium-codecs-ffmpeg-extra-version.txt
Restart Vivaldi and test H.264/MP4 support via this page:
http://www.quirksmode.org/html5/tests/video.html
EOF
@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