Compiling FFMpeg (with libfdk-aac support) for MakeMKV

The place to discuss linux version of MakeMKV
Post Reply
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

Trying to compile the latest FFMpeg for the MakeMKV and
something has changed and it does not work anymore.


Here is what I did on my Debian 12 machine:

Code: Select all

sudo apt update -qq && sudo apt -y install \
  autoconf \
  automake \
  build-essential \
  cmake \
  git-core \
  libass-dev \
  libfreetype6-dev \
  libgnutls28-dev \
  libmp3lame-dev \
  libsdl2-dev \
  libtool \
  libunistring-dev \
  libva-dev \
  libvdpau-dev \
  libvorbis-dev \
  libxcb1-dev \
  libxcb-shm0-dev \
  libxcb-xfixes0-dev \
  meson \
  ninja-build \
  pkg-config \
  texinfo \
  wget \
  yasm \
  zlib1g-dev

Code: Select all

curl -kLO https://ffmpeg.org/releases/ffmpeg-7.0.2.tar.bz2
curl -kLO https://ffmpeg.org/releases/ffmpeg-7.0.2.tar.bz2.asc
curl https://ffmpeg.org/ffmpeg-devel.asc | gpg --import
gpg --verify ffmpeg-7.0.2.tar.bz2.asc ffmpeg-7.0.2.tar.bz2
tar -jxvf ffmpeg-7.0.2.tar.bz2
cd ffmpeg-7.0.2

Code: Select all

./configure \
  --prefix=/tmp/ffmpeg \
  --enable-static \
  --disable-shared \
  --enable-pic \
  --enable-libfdk-aac
Up untill here all good and no errors.

But on close inspection, I can see that the
"/tmp/ffmpeg" has not been created and all compiled in "~/ffmpeg-7.0.2/"
instead of the "/tmp/ffmpeg" and my guess it's probably
new policy in Debian 12.....

And when inspecting the "/tmp/ffmpeg/lib/pkgconfig" nothing there and
"~/ffmpeg-7.0.2/lib/pkgconfig" the "lib" DIR does not exist anymore
but instead has the following DIR's:

libavcodec
libavdevice
libavfilter
libavformat
libavutil
libpostproc
libswresample
libswscale


Any idea how to compile MakeMKV 1.77.7 on Debian 12 with the latest FFMpeg 7.0.2?
scjet
Posts: 11
Joined: Mon Sep 16, 2013 11:44 pm

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by scjet »

Rai4321 wrote:
Mon Sep 30, 2024 10:32 am
...
Up untill here all good and no errors.

But on close inspection, I can see that the
"/tmp/ffmpeg" has not been created ...
After you run your "./configure ...", you'll need to also run a "make install" in your "~/ffmpeg-7.0.2" folder.
The "/tmp/ffmpeg/..." folder will not be created until after you run:

Code: Select all

make install
Or, preferably;

Code: Select all

make -j$(nproc) install
Anyway, MakeMKV 1.17.8 is now out, <- you should use this instead.
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

The "~/ffmpeg-7.0.2" DIR was created after extracting
files from the "ffmpeg-7.0.2.tar.bz2" archive using

Code: Select all

"tar -jxvf ffmpeg-7.0.2.tar.bz2"

The "/tmp/ffmpeg" DIR should have been created
when FFMpeg was build,
but is instead build in "~/ffmpeg-7.0.2" on Debian 12 .....


As i understand it, when I want to include the support for
FLAC encoder that handles 24-bit audio I need to
enable "libfdk-aac" support when configuring FFMmpeg....

Which I did:

Code: Select all

./configure \
  --prefix=/tmp/ffmpeg \
  --enable-static \
  --disable-shared \
  --enable-pic \
  --enable-libfdk-aac
And then build it:

Code: Select all

make -j$(nproc)

But when the latest version of FFMpeg it's build,
a] it's NOT build in the specific PATH:
(even it's specified in the "configure" command) in:
/tmp/ffmpeg

b] there is NO more "PATH" to:
"../lib/pkgconfig"
that is needed at later stage when configuring and building "makemkv-oss"
in the DIR's when FFMpeg is build...

PATH to "/tmp/ffmpeg/lib/pkgconfig"
does not exists anymore ...when building FFMpeg
and is needed when building "makemkv-oss" with support for FLAC encoder
according to the Installation instructions:

Code: Select all

PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ./configure
make
sudo make install

So how does MakeMKV OSS know when configuring/building,
where to look for the "libfdk-aac" | PATH "../lib/pkgconfig" that does not exist
in FFMpeg Build DIR anymore???

I have checked and the instructions for installing
MakeMKV 1.17.8 for Linux are still the same
viewtopic.php?f=3&t=224
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

When building the MakeMKV - "makemkv-oss" with support for FLAC encoder
it points to NONE EXISTENT PATH in FFMpeg build .....

PKG_CONFIG_PATH=......./tmp/ffmpeg/lib/pkgconfig.....

Code: Select all

PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ./configure
make
sudo make install

In Debian 12, when building the FFMpeg, PATH
"/tmp/ffmpeg/lib/pkgconfig"
does not get created ........

So if one wants to build MakeMKV with FLAC encoder
and build the latest FFMpeg, what path should be used
as the one in the Installation guide does not exist ......??????
segfaulted
Posts: 94
Joined: Mon May 06, 2024 11:10 am

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by segfaulted »

Rai4321 wrote:
Wed Oct 02, 2024 6:10 pm
In Debian 12, when building the FFMpeg, PATH
"/tmp/ffmpeg/lib/pkgconfig"
does not get created ........
Did you do make install on ffmpeg after it's finished compiling?
The files won't magically appear in the prefix by itself.
scjet
Posts: 11
Joined: Mon Sep 16, 2013 11:44 pm

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by scjet »

Rai4321 wrote:
Wed Oct 02, 2024 11:30 am
...
As i understand it, when I want to include the support for
FLAC encoder that handles 24-bit audio I need to
enable "libfdk-aac" support when configuring FFMmpeg....
...
I have checked and the instructions for installing
MakeMKV 1.17.8 for Linux are still the same
viewtopic.php?f=3&t=224
libfdk-aac has nothing to do with flac.
aac and flac are two different audio encoder/decoders.
You need to install "libfdk-aac-dev", from your debian repo's for support in ffmpeg in order to use the AAC encoder.
Flac encoding is included with ffmpeg > version 2.0, and since your using version 7.* your fine.

You need to read this viewtopic.php?f=3&t=224
more carefully and follow the instructions to a tee.
scjet
Posts: 11
Joined: Mon Sep 16, 2013 11:44 pm

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by scjet »

LMDE 6 (a Default installation, updated and upgraded): Based on Debian 12 (Bookworm):
#################################################################################
#1. Download all the below to /tmp, and extract both makemkv oss (source), and bin files.
viewtopic.php?f=3&t=224 <-(Using this as my guide)
makemkv-bin-1.17.7.tar.gz
makemkv-oss-1.17.7.tar.gz

Code: Select all

cd /tmp && gzip -d makemkv-bin-1.17.8.tar.gz && tar -xvf makemkv-bin-1.17.8.tar
cd /tmp && gzip -d makemkv-oss-1.17.8.tar.gz && tar -xvf makemkv-oss-1.17.8.tar

#2. Install dependencies for ffmpeg and makemkv (including nasm and libfdk-aac-dev and some BD drive extras).
Update: (for a pure Debian12/bookworm/stable install from scratch, for example: debian-live-12.7.0-amd64-cinnamon.iso, make sure to add the appropriate deb-multimedia bookworm repo in /etc/apt/sources.list from https://deb-multimedia.org/ -You'll need this for libfdk-aac-dev, ...)

Code: Select all

sudo apt-get update
sudo apt dist-upgrade
sudo apt install autoconf automake build-essential cmake git-core libass-dev libfreetype6-dev libgnutls28-dev libmp3lame-dev libsdl2-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev meson ninja-build pkg-config texinfo wget yasm zlib1g-dev                                                                                                  
sudo apt install libfdk-aac-dev libunistring-dev libbluray-dev libcdparanoia-dev libcdio-dev libcdio-paranoia-dev libc6-dev libssl-dev libexpat1-dev libavcodec-dev libgl1-mesa-dev nasm qtbase5-dev
#3. Get latest ffmpeg source files and compile:

Code: Select all

cd /tmp && wget -O ffmpeg-7.0.2.tar.bz2 https://ffmpeg.org/releases/ffmpeg-7.0.2.tar.bz2 && tar xjvf ffmpeg-7.0.2.tar.bz2
cd /tmp/ffmpeg-7.0.2
./configure --prefix=/tmp/ffmpeg --enable-static --disable-shared --enable-pic --enable-libfdk-aac
make -j$(nproc) install
#4. Build the makemkv-oss source with latest ffmpeg:

Code: Select all

cd /tmp/makemkv-oss-1.17.8
PKG_CONFIG_PATH=/tmp/ffmpeg/lib/pkgconfig ./configure
make -j$(nproc)
sudo make install
#5. Create/Merge the makemkv bin executables:

Code: Select all

cd /tmp/makemkv-bin-1.17.8
make -j$(nproc)
# hit "q" to quit the eula, and type "yes" to accept the license.
sudo make install
#6. Modify the MakeMKV application Icon line in:

Code: Select all

/usr/share/applications/makemkv.desktop
# with,
Icon=/usr/share/icons/hicolor/64x64/apps/makemkv.png
#7. Re-login, or Reboot; run MakeMKV and Register with your key:

#8. Select between "Default", "FLAC", or "AAC-stereo" Profiles:

Code: Select all

MakeMKV -> View -> Preferences -> General -> Expert mode -> Advanced -> (option) Profiles
############################################################################

-everything worked for me, testing makemkv as well as utilizing the (lossless)"Default", (lossless)"FLAC", and (lossy)"AAC-stereo" (Audio-encoding) mkv Profiles.
And, btw, the above also worked flawlessly for Mint 21.*/Mint 22/Ubuntu 22.02/24.04/...

So, if it still fails for you, in your Debian 12, then it is likely due to your Debian 12 installation and configuration, and/or missing crucial pkg dependencies that are at fault, ...?
Cheers.
Last edited by scjet on Sat Oct 05, 2024 2:17 pm, edited 9 times in total.
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

Thank you for taking your time and going through the setup again.

I have tried it on a brand new install of Debian 12.


View the recording at: https://asciinema.org/a/ZiwhBSrRuWyJy3SmOS0lMgJ7T
(Recordings uploaded from unrecognized systems, such as this one, are automatically
deleted 7 days after upload.)


1]
Why are you configuring "PKG_CONFIG_PATH environment variable" in step #4
for "makemkv-oss" to a NON EXISTENT DIR = /tmp/ffmpeg/lib/pkgconfig?

as you can see from my setup of FFMpeg there is no "/tmp/ffmpeg/lib/pkgconfig" created
during/after the build ......
and there is no "/tmp/ffmpeg-7.0.2/lib/pkgconfig" either.


2]
What is the purpose of setting the "PKG_CONFIG_PATH environment variable"
to a non existent PATH when building "makemkv-oss" ?



3]
Do you have the DIRs:
"/tmp/ffmpeg/lib/pkgconfig"
or
"/tmp/ffmpeg-7.0.2/lib/pkgconfig"
created when you build the FFMpeg?


I have also checked the man page for the:
pkgconf — a system for configuring build dependency information
and it states the following

Code: Select all

PKG_CONFIG_PATH
             List of secondary directories where ‘.pc’ files are looked up.

When looking for *.pc files in FFMpeg Build I get the following results:

Code: Select all

rai4321@debian12:/tmp/ffmpeg-7.0.2$ find -name "*.pc*" -print
./libavdevice/libavdevice.pc
./libavcodec/libavcodec.pc
./doc/examples/pc-uninstalled/libavcodec-uninstalled.pc
./doc/examples/pc-uninstalled/libavdevice-uninstalled.pc
./doc/examples/pc-uninstalled/libavfilter-uninstalled.pc
./doc/examples/pc-uninstalled/libavformat-uninstalled.pc
./doc/examples/pc-uninstalled/libswscale-uninstalled.pc
./doc/examples/pc-uninstalled/libavutil-uninstalled.pc
./doc/examples/pc-uninstalled/libswresample-uninstalled.pc
./libswresample/libswresample.pc
./libswscale/libswscale.pc
./libavutil/libavutil.pc
./libavfilter/libavfilter.pc
./libavformat/libavformat.pc


Should the "PKG_CONFIG_PATH environment variable" path for building "makemkv-oss" be:

Code: Select all

PKG_CONFIG_PATH=/tmp/ffmpeg-7.0.2/lib* ./configure


Also, running:

Code: Select all

rai4321@debian12:/tmp/ffmpeg-7.0.2$ ./ffmpeg -hide_banner -buildconf

  configuration:
    --prefix=/tmp/ffmpeg
    --enable-static
    --disable-shared
    --enable-pic
    --enable-libfdk-aac
shows that "--prefix=/tmp/ffmpeg" has been set to be build in "/tmp/ffmpeg"
but FFMpeg is build in the same DIR and that is "/tmp/ffmpeg-7.0.2/" instead of "/tmp/ffmpeg"
so why is the flag in FFMpeg config, if it does not work?

I'm simply trying to understand the whole process rather then COPY/PASTE the commands .....
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

I think I am getting the hang of it :)

The "MakeMKV 1.17.8 for Linux is available" guide says:

OPTIONAL: Building with latest "libavcodec"
Starting with version 1.8.6 MakeMKV links directly to libavcodec.

Please note that most distributions ship a very outdated version of libavcodec (either from ffmpeg or libav projects).

You will have to compile a recent ffmpeg (at least 2.0) if you need a FLAC encoder that handles 24-bit audio.

Also you will have to enable libfdk-aac support in ffmpeg in order to use AAC encoder.

Starting from version 1.12.1 DTS-HD decoding is handled by ffmpeg as well, so you would need a recent one.


So, while the mystery of why the FFMpeg does not build in the "/tmp/ffmpeg/"
is still here, I have made some progress.

Trying to build the "makemkv-oss" with specific "PKG_CONFIG_PATH environment variable"
yields on two machines different results.

On Debian 12 with FFMpeg installed using (apt) and version 6.0.1, but also
building the latest FFMpeg 7.0.2 in "/tmp/ffmpeg-7.0.2/"
when running config with the following PATH:

Code: Select all

PKG_CONFIG_PATH=~/Install/ffmpeg-7.0.2/libavcodec/ ./configure
I would get this ERROR:

Code: Select all

checking for libavcodec libavutil... no
configure: error: Package dependency requirement 'libswresample >= 5.1.100' could not be satisfied.
Package 'libswresample' has version '4.10.100', required version is '>= 5.1.100'
Package dependency requirement 'libavutil >= 59.8.100' could not be satisfied.
Package 'libavutil' has version '58.2.100', required version is '>= 59.8.100'.
On Debian 12 without FFMpeg installed using (apt),
but only build latest version 7.0.2 in "/tmp/ffmpeg-7.0.2/"
when running config with the following PATH:

Code: Select all

PKG_CONFIG_PATH=~/Install/ffmpeg-7.0.2/libavcodec/ ./configure
I would not get an ERROR ;)

Code: Select all

checking for libavcodec libavutil... yes
checking for gcc options needed to detect all undeclared functions... none needed
checking whether LIBAVCODEC_VERSION_MAJOR is declared... yes
checking LIBAVCODEC_VERSION_MAJOR... 59
checking whether avcodec_send_frame is declared... yes
checking for struct AVChannelLayout... yes
checking for av_log_format_line... yes
checking for AVCodecParserContext.duration... yes
checking for av_codec_iterate... yes
checking for Qt5Core Qt5Gui Qt5Widgets Qt5DBus... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: creating libffabi/src/ffabicfg.h
config.status: libffabi/src/ffabicfg.h is unchanged
config.status: executing libtool commands
And MakeMKVOSS would compile I believe with the latest
decoding and encoding API, and all the supported codecs from FFMpeg :)


#libav*
https://trac.ffmpeg.org/wiki/Using%20libav*

"libavcodec" provides a decoding and encoding API, and all the supported codecs.
Last edited by Rai4321 on Mon Oct 07, 2024 9:06 am, edited 1 time in total.
scjet
Posts: 11
Joined: Mon Sep 16, 2013 11:44 pm

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by scjet »

Rai4321 wrote:
Fri Oct 04, 2024 5:18 pm
I think I am getting the hang of it :)
...
So, while the mystery of why the FFMpeg does not build in the "/tmp/ffmpeg/..."
...
There is NO "mystery" here.
ffmpeg actually builds fine in "/tmp/ffmpeg/..." if you would just follow the instruction guide given in: viewtopic.php?f=3&t=224
AND, it works fine, for me, in Debian 12(bookworm)/LMDE 6/Ubuntu 22.04/24.04/Mint 21.*/22.*/..., as I've tested.

Good luck.
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

As you can see from the below "asciinema" recordings on a brand new VPS
compiling of the latest FFMpeg 7.1 on Debian 12 results with the "bin" files
being compiled in the unpacked TAR archive DIR,
rather then specific location :(



View the recording at:
https://asciinema.org/a/9wnvPUHz8Z2g5A85u0UYiYxcn

This asciinema CLI hasn't been linked to any asciinema.org account.

Recordings uploaded from unrecognized systems, such as this one, are automatically
deleted 7 days after upload.


I'm trying to attach all (*.cast, *.txt and *gif) files so when
the link expires after 7 days, you can still play/view the recording.
(But getting an: Error - HTTP error.) to upload any sort of file to forum txt, zip, gif ...:(


679367.cast - Original asciicast v2 recroding (744.7 K)
https://anonpaste.io/share/15601ddafe

679367.txt - Plain text version (367.6 K)
https://anonpaste.io/share/e881d0a9aa

679367.gif - Animated GIF (274.9 M)
https://anonpaste.io/share/762b059b00

MakeMKV+FFMpeg+Install-Notes.txt
https://anonpaste.io/share/93b01252c6
https://paste.debian.net/1331575
Rai4321
Posts: 18
Joined: Mon Sep 30, 2024 10:11 am

[SOLVED] Re: Compiling FFMpeg (with libfdk-aac support) for MakeMKV

Post by Rai4321 »

segfaulted wrote:
Thu Oct 03, 2024 6:15 am
Rai4321 wrote:
Wed Oct 02, 2024 6:10 pm
In Debian 12, when building the FFMpeg, PATH
"/tmp/ffmpeg/lib/pkgconfig"
does not get created ........
Did you do make install on ffmpeg after it's finished compiling?
The files won't magically appear in the prefix by itself.
I missed your post...

Nope :(
And this is where the problem is ...... :)
Thank you everyone and for your patience ;)


Setting the "prefix":

Code: Select all

./configure \
  --prefix=/tmp/ffmpeg \
is to "set" where it will be "installed" with the

Code: Select all

sudo make install
and I guess that is the part that I did not understand ......
and I did not run the "sudo make install" as I assumed
it would over write my current version of FFMpeg
and wanted to avid this .....
Post Reply