Skip to content

Instantly share code, notes, and snippets.

@BlackIkeEagle
Forked from ruario/h264-vivaldi-linux.md
Last active May 6, 2019 09:34
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BlackIkeEagle/5c00face3c7a0f98847a to your computer and use it in GitHub Desktop.
Save BlackIkeEagle/5c00face3c7a0f98847a to your computer and use it in GitHub Desktop.
Using H.264 in Vivaldi for Linux

How to use H.264 support In Vivaldi, via an alternative FFMpeg library

Intro

The following is a quick guide to get tthis working on various Linux distros. As a side note, if you have Chrome installed alongside Vivaldi, Netflix should also work after making these changes.

Ubuntu

Install chromium-codecs-ffmpeg-extra

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

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

Arch Linux

Install vivaldi-snapshot from AUR

git clone https://aur.archlinux.org/vivaldi-snapshot.git
cd vivaldi-snapshot
makepkg

Install vivaldi-ffmpeg-codecs from AUR

git clone https://aur.archlinux.org/vivaldi-ffmpeg-codecs.git
cd vivaldi-ffmpeg-codecs
makepkg

Install from unofficial repo

You can also install both packages from the [herecura] repo.

Test if all media is supported

Other distros

If your distro does not provide a package with a suitable lib, you can probably use the one from Ubuntu.

Fetch a package

64bit Linux
wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_45.0.2454.101-0ubuntu0.14.04.1.1099_amd64.deb
32bit Linux
wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_45.0.2454.101-0ubuntu0.14.04.1.1099_i386.deb

Extract the lib from the package

ar p chromium-codecs-ffmpeg-extra_45.0.2454*.deb data.tar.xz | tar xJf - ./usr/lib/chromium-browser/libs/libffmpeg.so --strip 5

Note: ar is from the GNU binutils package.

Installing in the Vivaldi directory

Issue the following as root (or prefaced with sudo):

install libffmpeg.so /opt/vivaldi-snapshot/lib/libffmpeg.so

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

Building your own replacement libffmpeg.so

If you don't want to use the file in the package provided by Ubuntu, you can compile your own.

Installing build dependencies

Ubuntu, Debian & Mint

sudo apt-get update && sudo apt-get install automake build-essential libtool pkg-config yasm zlib1g-dev 

Fedora

sudo dnf install autoconf automake gcc gcc-c++ libtool make nasm pkgconfig zlib-devel 

openSUSE

zypper in -t pattern devel_basis 

Other distros

  • autoconf
  • automake
  • gcc
  • gcc-c++
  • libtool
  • make
  • nasm (or yasm)
  • pkg-config
  • the zlib development support files

Fetch and unpack the appropriate Chromium source archive

CHRVER=45.0.2454.26
wget http://commondatastorage.googleapis.com/chromium-browser-official/chromium-$CHRVER.tar.xz
tar xf chromium-$CHRVER.tar.xz
cd chromium-$CHRVER

Fetch and configure Depot Tools

git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git
export PATH="$PATH:`pwd`/depot_tools"

Build libffmpeg.so

./build/gyp_chromium --depth . -Dcomponent=shared_library -Dffmpeg_branding=ChromeOS -Dclang=0
ninja -C out/Release ffmpeg

Note: On systems that don't use PulseAudio (e.g. Slackware), you should also include the define -Duse_pulseaudio=0.

Copy the lib into your Vivaldi install

Issue the following as root or prefaced with the sudo command:

install out/Release/lib/libffmpeg.so /opt/vivaldi-snapshot/lib/libffmpeg.so

Restart browser

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

Tips for package maintaners

If you repackage Vivaldi browser for your distro, you might want to consider making a vivaldi-snapshot-ffmpeg-codecs package containing a replacement ffmpeg library. It is suggested that you place this library in the directory /opt/vivaldi-snapshot/alt_ffmpeg.

To ensure that Vivaldi detects and prefers the replacement libffmpeg.so stored there, apply the following patch to the Vivaldi startup script (/opt/vivaldi-snapshot/vivaldi-snapshot):

--- vivaldi-snapshot.original
+++ vivaldi-snapshot
@@ -45,13 +45,8 @@
 fi
 
 # Find libffmpeg.so with additional codecs.
-CHR_CODECS_CH="/usr/share/doc/chromium-codecs-ffmpeg-extra/changelog.Debian.gz"
-if [ -r $CHR_CODECS_CH ]; then
-  CHR_CODECS_VER=$(gzip -cd $CHR_CODECS_CH |
-    sed -n '1s/chromium-browser (\(\([0-9]\+\.\)\{3\}\).*/\1/p')
-  if [ "$CHR_CODECS_VER" = "45.0.2454." ]; then
-    FFMPEG_LD_LIBRARY_PATH=":/usr/lib/chromium-browser/libs"
-  fi
+if [ -r "$HERE/alt_ffmpeg/libffmpeg.so" ]; then
+  FFMPEG_LD_LIBRARY_PATH=":$HERE/alt_ffmpeg"
 fi
 # Set LD_LIBRARY_PATH to prefer our libs, excluding $HERE/lib/libffmpeg.so if
 # an alternative ffmpeg was found.
@Kabouik
Copy link

Kabouik commented Dec 11, 2016

Thanks for the thorough guide. On Solus 1.2.1, I have had to use a different path to make it work so it may be worth reporting it.

I fetched the following package:
wget http://security.ubuntu.com/ubuntu/pool/universe/c/chromium-browser/chromium-codecs-ffmpeg-extra_45.0.2454.101-0ubuntu0.14.04.1.1099_amd64.deb

Extracted the lib from the package:
ar p chromium-codecs-ffmpeg-extra_53.0.2785.143-0ubuntu0.16.04.1.1257_amd64.deb data.tar.xz | tar xJf - ./usr/lib/chromium-browser/libs/libffmpeg.so --strip 5

Installed it in the Vivaldi directory (differs from what is written in the original how-to):
sudo install libffmpeg.so /usr/share/vivaldi-snapshot/lib/libffmpeg.so

Seems to work correctly now.

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