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

I would also suggest installing the devpkg-libva bundle before building ffmpeg so configure will pickup on the vaapi hardware acceleration.

you can check if ffmpeg is build with support with the following

ffmpeg -hwaccels

Which should then have output like the following

ffmpeg version 4.1.4 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9 (Clear Linux OS for Intel Architecture)
  configuration: --prefix=/usr/local --enable-shared
  libavutil      56. 22.100 / 56. 22.100
  libavcodec     58. 35.100 / 58. 35.100
  libavformat    58. 20.100 / 58. 20.100
  libavdevice    58.  5.100 / 58.  5.100
  libavfilter     7. 40.101 /  7. 40.101
  libswscale      5.  3.100 /  5.  3.100
  libswresample   3.  3.100 /  3.  3.100
Hardware acceleration methods:
vaapi
3 Likes

RPM Fusion is a community maintained project, not backed by Fedora or Red Hat, indeed.
If some wants to contribute build for clear linux, that’s someone that can be looked into.
https://rpmfusion.org/Contributors

What would be the preferred form for complementary build ?

  • RPM repository with few packages dedicated to clearlinux ?
  • an image overlay
  • else ?

/me is the RPM Fusion project coordinator.

RPM’s are not the preferred method here. Even flatpak would be better.

Thanks I’ll update the guide accordingly.

I’ve tried to rebuild couple of Fedora/SUSE packages on CL and seems like RPM/mock was highly patched: many macros doesn’t works and tons of another adventures.

anyone can help to run music with mp4a aac codec in clear linux?

Hi @YeQais and welcome. You could try installing the Celluloid (formerly GnomeMpv) Flatpak.

1 Like

Thanks. This worked for me. Firefox after installing ffmpeg now plays videos from srf.ch it didn’t before.
Why does Eolie play these videos without ffmpeg?
https://wiki.gnome.org/Apps/Eolie
https://clearlinux.org/software/flathub/eolie

Eolie is from Flathub and is likely bundle ffmpeg with the browser.

Eolie flatpak bundles gst-libav which is a fork of ffmpeg.

1 Like

This thread has spiralled into a confusing fragmented cluster of information.

Who has a real current existing full command line instruction for ffmeg on NON desktop Clear Linux ie live-server.

We need server to have ffmpeg which will be used by PHP to generate video thumbnails for a website.

sudo swupd bundle-add c-basic devpkg-libva

mkdir ~/build && cd ~/build

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

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

sudo ldconfig

Below the second last two command the OP said “this should be enough for Firefox to reference.”

Now in my case on server install there is no need for Firefox, does these last two commands need to be ran?

Then the second guy comes in and confuses everything with:

“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”

Couldn the paste in the full command with his suggested correction?

Where does this fit into the command? I see a different version number of ffmpeg he references.

Original poster edited 4 times, does the final edit take into consideration of the second guys post? or any of the replied comments?

Would be nice to post the commands with a line space between each so so not confused of a single command wrapped onto another line.

The OP intended this guide to show us how to build the ffmpeg libraries that Firefox needs to decode and render html5 multimedia content, not how to build the complete ffmpeg package (and dependencies) that is capable of transcoding. You may find my article, Tips and Techniques for building ffmpeg, to be useful.

1 Like

Hi Nirgendsdorf,
Yes I read your article. Yes maybe ‘some’ useful info.

It is not a Clear Linux specific guide.

These are guides to Compile FFmpeg on CentOS and Windows.

So in the end it doesn’t define how to Compile FFmpeg on Clear Linux.

If you’ve actually compiled on Clear Linux by using the info in guide to Compile FFmpeg on CentOS and made modifications to compile specifically on Clear Linux please share and post details of your process.

Thanks

duplicate and cannot delete must have been in another tab

I absolutely did, and use my build all the time. What isn’t in the guide, I put in my article. I even put in the command line and environment variables I use to configure my build on CL. I don’t know what else I can offer to you…

Can you just post exactly what you used from the CentOS article?

Exactly did you do from that article is what i’m asking, there’s along list of steps under " Compilation & Installation":
NASM
Yasm
libx264
libx265
libfdk_aac
libmp3lame
libopus
libvpx
FFmpeg

You ran each one of those command?
and then?

did you use the first command posted by OP:

sudo swupd bundle-add c-basic devpkg-libva

Also in Clear Linux i though installing to /usr/local/lib/ will get wiped out by swupd?

Someone said:

" > There is nothing special about compiling ffmpeg on clearlinux. The last time I did it I just downloaded it and did configure and make .

Now try to compile with libx264 and libx265. Good luck!"

Did you do any of these commands?

sudo swupd bundle-add c-basic devpkg-libva

mkdir ~/build && cd ~/build

curl -LO https://ffmpeg.org/releases/ffmpeg-4.2.tar.bz2

tar jxf ffmpeg-4.2.tar.bz2

cd ffmpeg-4.2

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

These are assemblers that are necessary to build some of ffmpeg’s dependencies, and ffmpeg itself. they are already available as CL bundles:

sudo swupd bundle-add nasm yasm

libx264
libx265
libfdk_aac
libmp3lame
libopus
libvpx

These are some of ffmpeg’s dependencies; specifically, they are video and audio encoders. If you want to encode in any of these formats, you have to download the sources for each one, and compile them. Each of these will build a library, which will be picked up when you build ffmpeg. You have to make install each library (I recommend the default location prefix /usr/local), and put --enable-libx264 --enable-libx265, etc. in your configure command line.

did you use the first command posted by OP:

sudo swupd bundle-add c-basic devpkg-libva

You add c-basic if you haven’t yet installed the compiler and its tool chain. devpkg-libva enables ffmpeg to use hardware acceleration if your system has it.

Also in Clear Linux i though installing to /usr/local/lib/ will get wiped out by swupd?

No. usr/local/* is designated on all unix-like systems for software built and installed by the user. ffmpeg puts its binaries there by default.

Someone said:

There is nothing special about compiling ffmpeg on clearlinux. The last time I did it I just downloaded it and did configure and make.

That works if all you want is a minimal ffmpeg, or if you just want the ffmpeg decoders for Firefox. If you want a full-featured ffmpeg, you have to get sources for the features you want, compile then install them, and then --enable them when you configure ffmpeg.

Now try to compile with libx264 and libx265. Good luck!

If you follow the steps, it will work.

Did you do any of these commands?

sudo swupd bundle-add c-basic devpkg-libva

Yes.

mkdir ~/build && cd ~/build

Yes. It is good practice to build outside the directory where your sources are.

curl -LO https://ffmpeg.org/releases/ffmpeg-4.2.tar.bz2

No. I use my web browser to download sources. I also use the ffmpeg nightly snapshots because they have the latest features and fixes, and they are almost always stable and reliable.

tar jxf ffmpeg-4.2.tar.bz2

No. tar jxf ffmpeg-snapshot.tar.bz2

cd ffmpeg-4.2

No. cd build and then ../ffmpeg/configure

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

Yes, though this is not necessary for ffmpeg; Firefox apparently needs this so that it can find ffmpeg’s libraries.

Hopefully the CentOS guide and my article will make more sense, now. There is also a Generic Compilation Guide on the ffmpeg website that may also be of use to you.

2 Likes

Hey Nirgendsdorf,

Thanks for clarifying, starting to make more sense now.

So for my purpose requiring ffmpeg I need either of the two libraries to extract a frame from a video and use it as an image thumbnail.

php-ffmpeg (Extracting image frame from video)

FFmpegPHP (creating thumbnail images from movies)

Both libraries don’t go into much detail of ffmpeg requirements just that:
“ffmpeg and ffprobe binaries” are needed.

Would a “minimal ffmpeg” satisfy?

I’m have Clear Linux live server running Nginx, MariaDB, PHP. Not a desktop.

It should do, if the image (thumbnail) format you want is one of the older web-friendly ones (jpeg, png, gif). If you want WebP, you’ll have to get the library. FFMPEG has a muxer called ‘image2’ that extracts video frames to still images. Though I haven’t used the image conversion features of ffmpeg, I know they are there. All that is available without adding any extra libraries.

Please note that I don’t speak PHP so I haven’t looked at the PHP modules you want to use.

So does this sequence look right?
I’m unsure about the PKG_CONFIG_PATH for each if is incorrect would you mind making all corrections and then maybe we can paste it to your “Tips and techniques for building ffmpeg” thread, so anyone in the future has simple step by step commands guaranteed to work.

================================================================

sudo swupd bundle-add nasm yasm

sudo swupd bundle-add c-basic devpkg-libva

mkdir ~/ffmpeg_sources

cd ~/ffmpeg_sources

git clone --depth 1 https://code.videolan.org/videolan/x264.git

cd x264

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/lib64/haswell/pkgconfig" ./configure –prefix="$HOME/ffmpeg_build" –bindir="$HOME/bin" --enable-static

make

make install

================================================================

cd ~/ffmpeg_sources

hg clone https://bitbucket.org/multicoreware/x265

cd ~/ffmpeg_sources/x265/build/linux

cmake -G “Unix Makefiles” -DCMAKE_INSTALL_PREFIX="$HOME/ffmpeg_build" -DENABLE_SHARED:bool=off …/…/source
make

make install

================================================================

cd ~/ffmpeg_sources

git clone --depth 1 https://github.com/mstorsjo/fdk-aac

cd fdk-aac

autoreconf -fiv

./configure --prefix="$HOME/ffmpeg_build" --disable-shared

make

make install

================================================================

cd ~/ffmpeg_sources

curl -O -L https://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz

tar xzvf lame-3.100.tar.gz

cd lame-3.100

./configure --prefix="$HOME/ffmpeg_build" --bindir="$HOME/bin" --disable-shared --enable-nasm

make

make install

================================================================

cd ~/ffmpeg_sources

curl -O -L https://archive.mozilla.org/pub/opus/opus-1.3.1.tar.gz

tar xzvf opus-1.3.1.tar.gz

cd opus-1.3.1

./configure --prefix="$HOME/ffmpeg_build" --disable-shared

make

make install

================================================================

cd ~/ffmpeg_sources

git clone --depth 1 https://chromium.googlesource.com/webm/libvpx.git

cd libvpx

./configure --prefix="$HOME/ffmpeg_build" --disable-examples --disable-unit-tests --enable-vp9-highbitdepth --as=yasm

make

make install

================================================================

cd ~/ffmpeg_sources

curl -O -L https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2

tar xjvf ffmpeg-snapshot.tar.bz2

cd ffmpeg

export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/lib64/haswell/pkgconfig" ./configure
–pkg-config-flags=–static
–extra-cflags=-I/usr/local/include
–extra-ldflags="-L/usr/local/lib -L/usr/local/lib64 -flto -fuse-linker-plugin"
–ar=gcc-ar
–extra-libs=-lpthread -lm
–enable-libmp3lame
–enable-libopus
–enable-libvpx
–enable-libx264
–enable-libx265
–enable-libfdk-aac
–enable-gpl
–enable-version3
–enable-nonfree
–disable-podpages
–enable-hardcoded-tables \

make

make install

hash -d ffmpeg

================================================================