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

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.

2 Likes

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…

1 Like

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.

4 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

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

2 Likes

At a BRIEF glance, it looks MOSTLY alright:

  • I’m not sure about how you would reset PKG_CONFIG_PATH, as I used the default locations for everything. You might want to export that variable: export PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"

  • I’m not sure why you want to put everything in your $HOME directory, but that’s OK I guess, as I recall the CentOS guide does it that way.

  • It’s not a great idea to build in your source tree, because you can delete the contents of a separate build directory if you need to start over instead of depending on make clean to work, but that’s OK too.

  • I can’t advise you on libx265 as I’m not too familiar with cmake, I use the little x265/build/linux/make-Makefiles.bash ncurses menu script to configure, but it looks like your commands would build that library to be static, which is the main thing.

  • I might enable a few more options when configuring my libraries, but I don’t remember what they are now. I would need to review the help files (and ./configure --help) for them again.

  • In building ffmpeg, you have '--enable'd several libraries which you haven’t built: libaom, libvidstab, libvorbis, and libtheora. The ffmpeg build script will look for those, and fail when it doesn’t find them. For a step-by-step guide like yours, you want to enable only the options you have prepared in advance.

  • Please read my second post in “Tips and techniques for building ffmpeg,” which is about how to build ffplay, and suggests reasons why you might want to do so. Your guide here will not build it.

The best way to make sure your guide works the way you want is to follow it and see what happens. All I had to work with was ffmpeg’s guide for CentOS; I had to figure out the rest, myself. Anything that you or anyone else can contribute to that thread will only help the community. :slightly_smiling_face:

3 Likes

Italicised and Bolded the following in libraries that have the directive:
–prefix=“$HOME/ffmpeg_build”

Do these need changing now to reflect command:

export PKG_CONFIG_PATH='/usr/local/lib/pkgconfig:/usr/local/lib64/pkgconfig:/usr/lib64/pkgconfig:/usr/lib64/haswell/pkgconfig

After I used your advice in the ffmpeg and x264 sections?

(removed the libraries:
libaom
libvidstab
libvorbis
libtheora

in the ffmpeg configure that we don’t install above)

1 Like

FFmpeg Static Builds

https://www.johnvansickle.com/ffmpeg/

Will these work? Could save a lot of time and effort, download and dump in /usr/local/lib

1 Like

Interesting, as you wrote, it would be really simple to copy the already built binary.
However, the FAQs mention to copy both ffmpeg and ffprobe to usr/local/bin, and not /usr/local/lib.

Has anyone successfully made Firefox work with this static build?

This pre-build binary worked for me but my use case is to use ffmpeg with php to create video thumbnails on bare metal server. I put ffmpeg in /usr/local/bin, installed php-ffmpeg with composer and all is working well.

For your use, just put the binaries in the location that i s mentioned above in this thread /usr/local/lib and follow their instructions on the configuration for Firefox which is your intended purpose.

Not sure why these guys went to all the trouble trying to compile from source, when all that effort is done by someone else, it’s simply drag and drop.

1 Like

I copied ffmpeg and ffprobe into /usr/local/lib, then ran

sh -c 'echo /usr/local/lib >>/etc/ld.so.conf'
ldconfig
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ${HOME}/.config/firefox.conf

with admin privileges. However — even after a reboot — I’m not able to play videos on Firefox.
Do you have any idea of what could be wrong? Thanks in advance. :grin:

Looking at proc maps (i.e. what files firefox is loading), it shows this.

7f2b32240000-7f2b3226b000 rw-p 00cf4000 08:03 4850011 /usr/local/lib/libavcodec.so.58.54.100
7f2b39866000-7f2b39867000 rw-p 00094000 08:03 4850020 /usr/local/lib/libavutil.so.56.31.100
7f2b4a11f000-7f2b4a122000 r–p 00000000 08:03 4850014 /usr/local/lib/libswresample.so.3.5.100

It is loading the shared libraries. The static build contains no libraries, therefore is no replacement for these instructions to build ffmpeg to override the CL provided version.

You could try putting the files in /usr/local/bin instead as they are binaries and ensuring that /usr/local/bin is in the PATH variable. (Putting them in /usr/local/lib does nothing as they aren’t libraries). If firefox wants the libraries (which means the static version won’t work with the binaries in /usr/local/bin), then ignore the static version and build it via the instructions provided.

The static version will only work where the program runs the ffmpeg binary directly (then libraries don’t matter), while most programs will want the libraries.

1 Like

I understand, thanks for the clarification. :grin:

Is there a way to statically compile and install those lib*.so shared libraries — and make them easily available for the community — in the same copy-paste way of the static ffmpeg binary?