Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to enable HTML5 MP4 (H.264/AAC) video and MP3 audio in Vivaldi for Linux, via an alternative FFMpeg library

How to enable HTML5 MP4 (H.264/AAC) video and MP3 audio 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.

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.

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.

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. If your libffmeg.so is compiled from a Chromium that is too old, it could prevent Vivaldi from displaying any videos and/or cause crashes.

#!/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 ;;
i?86) ARCH=i386; DEB_ARCH=i386 ;;
esac
# Work out the VERSION
UBUNTU_PACKAGE=$(${SILENT_DL} http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/ | 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 "http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/${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
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

Thanks for this solution for all :) I have one question. Why we need use custom libffmpeg? We cant use default ffmpeg?

Owner

ruario commented Oct 19, 2015

Chromium patches FFMpeg. The default FFMpeg provided on distros does not include these patches and hence it is incompatible. There is also the issue that the system version is often a different version (older or newer) so would probably be incompatible anyway, in addition to the patches issue.

skobkin commented Oct 27, 2015

@ruario What do you think about this conversation with Opera developers?

Seems like Chromium can be patched to use system ffmpeg/libav.

On my Debian machine I had to install several dev-packages before being able to build the ffmpeg lib:
sudo apt-get install libcups2-dev libatk1.0-dev libgtk2.0-dev libxtst-dev libexif-dev libxss-dev libpci-dev libdbus-1-dev libgconf2-dev libgnome-keyring-dev

For pulseaudio support:
sudo apt-get install libpulse-dev

@matsbtegner they are being updated from time to time so the herecura links are mostly only usefull for Arch Linux users

Owner

ruario commented Mar 16, 2016

@matsbtegner Thanks, indeed I have not maintained this page as well as I would hope. Though it is up to date as I write this

@ruario do you have any web page to validate the installation ?

just a dumb question: if there are sources and can be installed right in place, why is the support not included in the snapshots and the beta by default? just tried the herecura repos from Fedora 23 using the latest vivaldi snapshot and it works fine

Owner

ruario commented Mar 16, 2016

@titilambert I linked to a suitable page several times in the instructions, (see my statements: "You can then test support on this page"). Use the first video labelled H.264/MP4. If is plays, all is good. ;)

P.S. If you just want to test audio support, this page is also handy.

Owner

ruario commented Mar 16, 2016

@JuanCAlpizar Not a dumb question. If you are unsure, it is always best to ask.

HTML5 media (audio and video) allows for the use of several different codecs. The most common ones (H.264, MP3 and AAC) are what I would call "proprietary" media codecs because they are patented and hence require various licenses to distribute software that can decode them. Each user costs the person distributing the software money. To an extent, these costs reduce as you gain more users (e.g. the licensor for H.264 gives discounts over certain numbers of users and you eventually hit a cap where these is no additional cost) but at our current size it is not viable for us to pay for a license for all our users and still fund the development of the browser.

The repositories I have linked to (that include binaries capable of decoding these codecs) are not associated with us. In addition, I am not a lawyer and cannot give legal advice but if I was to guess as to how they are able to distribute, I would assume that in the case of the Ubuntu repositories, they either paid for the licenses or they have some reason why they believe that they do need to pay for licenses. In the case of the herecura repo, it is maintained by a single individual in Europe, where software patents are not valid (to the best of my knowledge), so again I guess he should be fine.

DMKrow commented Mar 18, 2016

I needed to install the sysroot (Debian Wheezy) with
./build/linux/sysroot_scripts/install-sysroot.py --arch=amd64
prior to ./build/gyp_chromium, after that, things seemed to work fine - thanks.

@ghost

ghost commented May 2, 2016

With some x86 Linux it happend that Vivaldi on my Netbook MSI WInd U110 wont play MPEG4/H265 videos, even after installing package chromium-codecs-ffmpeg-extra or adding libffmpeg.so from herecura.

I opened vivaldi://gpu and discovered that GPU section is all shown as Software, but then CPU should render the videos. But that did not work. Video was Black or White, only with sound.

I could workaround the problem by starting vivaldi from shell as vivaldi --disable-gpu

noy88 commented May 16, 2016

Vivaldi will not open once the stable releases have been installed to /opt/vivaldi/lib/libffmpeg.so. Have to install the default libffmpeg.so to get it to launch again.

Anybody else getting this to work for stable Vivaldi?

EDIT: Nevermind, I was using the wrong bit version...

links are outdated.

chewi commented Jun 22, 2016

On Fedora 23, I have Chromium installed as well from the "Russian Fedora" repository. If you have that then you can just create a symlink pointing to /usr/lib64/chromium/lib/libffmpeg.so.

Some systems will not do hardware video decoding unless you route things via a suitable VDPAU driver, I have put together instructions for Debian jessie with an integrated Intel GPU which may help others.

Thanks jimdigriz. However, the directory in your instructions does not exist.

Everything worked fine in Vivaldi on Ubuntu until the latest snapshop. None of the other suggestions above work either. The flash recommended by https://help.vivaldi.com/article/install-flash-player-for-vivaldi/ can be installed but is disabled without any means to enable it. The suggestion at https://vivaldi.net/en-US/forum/vivaldi-browser-for-linux/14100-ubuntu-flash#71518 does not work either so its back to using Firefox unless I want to use Chrome itself or the chrome clone Opera. ... sign Oh well, maybe in the future if Vivaldi grows, licensing will not be an issue. Regardless, thanks for all the suggestions posted above.

Owner

ruario commented Dec 20, 2016

@matsbtegner @xchronox0 Thanks I finally updated the links

@DesertOutlaw for Flash use this. For H264 the document is now updated and Vivaldi has been made more robust in accepting a wider range of library versions.

cavariux commented Feb 1, 2017

Thanks for all, btw just some advice. The AUR version seems to be having some problems when compiling so use the herecura one ;)

JRetire commented Feb 13, 2017

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

argorain commented Mar 29, 2017

Hi! I tried to install ffmpeg library to latest stable (Vivaldi 1.8) but it is not working. I tried to use more recent chromium (57.0.2987.99 to be exact) but it failed on this error during gyp phase:

$ touch chrome/test/data/webui/i18n_process_css_test.html
$ ./build/gyp_chromium --depth . -Dcomponent=shared_library -Dffmpeg_branding=ChromeOS -Dclang=0
gyp: usage: gyp_chromium [options ...] [build_file ...]                                                                               
                                                                                                                                      
gyp_chromium: error: no build_file

Any ideas what is going on?
Thanks

Owner

ruario commented Mar 30, 2017

I would avoid against compiling your own replacement libffmpeg.so unless you are a package maintainer on a distro and want to offer a supporting package for your users. It is a lot of effort for little reward. Far better to run the attached script, which will fetch a suitable libffmpeg for you from Ubuntu and place it in a location Vivaldi will find it.

I have re-written most of the script. You no longer need root/sudo/superuser privileges to run it as the file is places in a user owned location.

tphecca commented Apr 3, 2017

The script worked great for me on OpenSUSE Tumbleweed with Vivaldi 1.8. Thanks!

Owner

ruario commented Apr 4, 2017

@tphecca great. Nice to hear it

Wow, just thank you :)

Works on Solus !

mxttie commented May 2, 2017

on opensuse leap, you can also install vivaldi-ffmpeg-codecs (though I did have to create a symlink /usr/lib64/vivaldi/lib/libffmpeg.so pointing to /opt/vivaldi/lib/libffmpeg.so)

mxttie commented May 3, 2017

i also tested the latest-proprietary-media.sh script now on opensuse leap 42.2. works flawlessly (netflix also tested). ruario, you rock :)

xioustic commented Jun 4, 2017

Worked for me in Fedora 25 today; thanks!

Lgofk commented Jun 5, 2017

Works on Ubuntu 16.04, thanks!

Hey, thanks a lot! This fix works on Solus OS, as well.

Woot! Worked on Fedora 25. Last hurdle to switch to vivaldi from firefox.

Works on Debian 10

Owner

ruario commented Oct 11, 2017

With the slow death of Unity it seems like the chromium-codecs-ffmpeg-extra is now (once again) the most likely source of this lib to be updated (for a while there it was oxideqt-codecs-extra), so I have updated this gist accordingly. If you were having issues, try again!

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