How-to: h264 etc. Support for Firefox (including ffmpeg install)

A brief how-to for h264 etc. support for Firefox (including ffmpeg install).

You’ll need the C compiler installed and packages to enable vaapi hardware acceleration

sudo swupd bundle-add c-basic devpkg-libva

Now create a build directory somewhere and cd into it.

mkdir ~/build && cd ~/build

Install ffmpeg

curl -LO https://ffmpeg.org/releases/ffmpeg-4.2.tar.bz2
tar jxf ffmpeg-4.2.tar.bz2
cd ffmpeg-4.2
./configure --prefix=/usr/local --enable-shared && make && sudo make install

If you haven’t already added /usr/local/lib to ld.so.conf, this is required before ffmpeg will work.

sudo sh -c 'echo /usr/local/lib >>/etc/ld.so.conf'
sudo ldconfig

Now this should be enough to make Firefox reference the new libraries, but for some reason it doesn’t. I suspect it might be an issue with Firefox upstream.

The below is a workaround, at least until Firefox is “fixed” (thanks to @miguelinux who posted this below)…

echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ${HOME}/.config/firefox.conf

Now verify Firefox by visiting https://www.youtube.com/html5

32 Likes

The current instructions will need a minor adjustment, as the directory name isn’t the same as the tarball.

i.e. cd $FFMPEG_PKGNAME translates to cd ffmpeg-4.1.3.tar.bz2 where the directory is ffmpeg-4.1.3

4 Likes

Yep, definitely works. Great timing, I was just about to post a query about which ffmpeg version to build for Firefox when your post appeared!

I use ffmpeg, but I build from the nightly snapshots. Good thing I build statically, so my libraries do not interfere with the shared ones I just built for Firefox!

2 Likes

Updated - thanks, @sunnyflunk!

1 Like

I am currently using the Firefox version installed by swupd. Do you know if the libraries created by these instructions will also work with the current official Mozilla build? My concern is with the version of ffmpeg. Do you know if the current official Mozilla build also works with version 4.1.3? Thanks!

Could I suggest to use curl -LO https://ffmpeg.org/releases/ffmpeg-4.1.3.tar.bz2instead.

Updated.

Can I ask why the preference for curl over wget?

CL patched libcurl to use autoproxy/transparent proxy, so if you are behind a proxy you don’t need to set the proxy variables.

https://clearlinux.org/documentation/clear-linux/guides/clearlinux/autoproxy

2 Likes

I’m not sure I understand exactly what you’re asking. I believe the version installed using swupd is actually just vanilla upstream, and it works just fine…

Hi! Thanks for your reply.

I had the impression that the swupd version is built from source by one of the Clear developers, with the usual optimizations and maybe some customizations. It occurred to me that it might be built against a different version of ffmpeg than the “official” Mozilla builds. As it turns out, the Mozilla builds also use ffmpeg 4.1.3. I installed the update, and it seems to work fine.

2 Likes

I did all the recommended steps - unfortunately there is no result. Still cannot play h264. What might be the reason for this?

There’s a flag in about:config of Firefox that you need to turn on.

1 Like

Thanks for your reply - could you specify, which flag you are referring to?

You shouldn’t need to enable any flags… Are you able to run ffmpeg from the command line?

1 Like

No - result:
ffmpeg: command not found
To install ffmpeg use: sudo swupd bundle-add kde-frameworks5-dev

Something probably went wrong at this step

./configure --prefix=/usr/local --enable-shared && make && sudo make install

Try splitting the commands out to try and pinpoint the issue.

$ ./configure --prefix=/usr/local --enable-shared
$ make
$ sudo make install
1 Like

Thanks for your help - unfortunatelly after the “make” command a flow of repeating commands appear, which do not stop anymore. No chance to enter the third command…

I made it - just had to wait a bit. It works now!
Thanks a lot!!

1 Like

Unfortunately firefox changed back to normal (no h.264 support) after a restart of the system…

Can you do
$ cat /etc/ld.so.conf
Then
$ cat ${HOME}/.config/firefox.conf
And post the output?