How to configure Qt 6.5.1 QtMultimedia to use custom FFmpeg installation?
-
I'm running Zorin OS 16.2 (which is derived from ubuntu, linux). I'm trying to build QT 6.5.1 from source. It's compiling fine, but none of the audio backends are enabled. I'm trying to use the ffmpeg qtmultimedia backend with my own custom build of ffmpeg, but I'm having trouble getting Qt to... I guess see that it's there? Link with it properly? I can't find much helpful information about this online.
I have the ffmpeg sources in
/home/eramne/Desktop/ffmpeg/src/ffmpeg-6.0
. I configure and compile it with the following:cd /home/eramne/Desktop/ffmpeg/src/ffmpeg-6.0 ./configure --prefix="/home/eramne/Desktop/ffmpeg/install/ffmpeg-6.0" --disable-programs --disable-doc --disable-debug --enable-network --disable-lzma --enable-pic --enable-openssl make && make install
The
/home/eramne/Desktop/ffmpeg/install/ffmpeg-6.0
folder is then populated with the folders "include", "lib", and "share".I have the Qt 6.5.1 sources in
/home/eramne/Qt/6.5.1/Src/
. I configure and compile it with the following:cd /home/eramne/Qt/6.5.1/Src/ export OPENSSL_USE_STATIC_LIBS=ON export QT_MEDIA_BACKEND=ffmpeg export QT_DEFAULT_MEDIA_BACKEND=ffmpeg ./configure -prefix "/home/eramne/Qt6.5.1/" -DFFMPEG_DIR="/home/eramne/Desktop/ffmpeg/install/ffmpeg-6.0" -release -openssl -openssl-linked -no-widgets -submodules qt5compat,qtbase,qtdeclarative,qtimageformats,qtmultimedia,qtshadertools,qtsvg,qttranslations ./configure -redo cmake --build . --parallel cmake --install .
(for some reason if i don't do ./configure -redo it doesn't give as detailed output, the build options don't show up? and the initial ./configure call seems to just use the previous/existing configuration while the -redo call works? idk, not very important, just a minor weird thing. but is there a way to clear/erase an existing configuration?)
In the output of the
./configure -redo
call (or the initial configure script call if it's my first time running it), it displays the "build options" section.The FFmpeg backend is shown to be disabled, indicating that I did something wrong in configuring it. Am I using the wrong command line option? or passing the wrong path in the
-DFFMPEG_DIR
option? Is this version of FFmpeg (6.0) not supported by Qt 6.5.1? Did I configure/compile FFmpeg wrong?Also, apparently none of the other audio backends are enabled, and the configure script gives a warning:
WARNING: No backend for low level audio found.
Is this a problem too? Is a low-level backend still required if the FFmpeg backend is working? If so, how can I get one of those to work?I can't find any other information in the output of the configure script that would be related.
When I try to run my app using this Qt installation, it predictably gives the following error:
could not load multimedia backend "" QtMultimedia is not currently supported on this platform or compiler.
-
I tried using Qt's own script with
cd /home/eramne/Qt/6.5.1/Src/ && source "coin/provisioning/common/unix/install-ffmpeg.sh" "linux"
I saw that it printed out
Setting environment variable FFMPEG_DIR to /usr/local/FFmpeg-n6.0.
, so I tried configuring Qt with./configure -prefix "/home/eramne/Qt6.5.1/" -DFFMPEG_DIR="/usr/local/FFmpeg-n6.0" -release -openssl -openssl-linked -no-widgets -submodules qt5compat,qtbase,qtdeclarative,qtimageformats,qtmultimedia,qtshadertools,qtsvg,qttranslations
and then with./configure -prefix "/home/eramne/Qt6.5.1/" -release -openssl -openssl-linked -no-widgets -submodules qt5compat,qtbase,qtdeclarative,qtimageformats,qtmultimedia,qtshadertools,qtsvg,qttranslations
, both still didn't work.maybe i need a low-level audio backend for the ffmpeg backend to show as enabled?
-
how do i get the pulseaudio backend working/enabled/configured?
-
oh! i installed the
libpulse-dev
package, now the pulseaudio backend is shown as enabled, but the ffmpeg backend still isn't.
i'll check https://github.com/qt/qt5/blob/6.5.1/coin/provisioning/qtci-linux-Ubuntu-20.04-x86_64/02-apt.sh and see if there's any other packages that I'm missingthis should really be in the documentation somewhere, like in https://doc.qt.io/qt-6/linux-requirements.html
-
i ran this script https://github.com/qt/qt5/blob/6.5.1/coin/provisioning/qtci-linux-Ubuntu-20.04-x86_64/02-apt.sh
now the gstreamer backend is shown as enabled, but still not ffmpeg -
ok, i don't remember what i did differently, but now the configure script is actually giving me useful information
it's printing out a lot more than before, although im running the exact same command
-- Checking for module 'libavdevice' -- No package 'libavdevice' found -- Checking for module 'libavfilter' -- No package 'libavfilter' found -- Checking for module 'libpostproc' -- No package 'libpostproc' found -- Could NOT find FFmpeg (missing: AVDEVICE_LIBRARIES AVDEVICE_INCLUDE_DIRS) -- Generated QtModulePlugins.cmake files for the following modules: Multimedia
that's something that i can work with
-
although, i already have those things?
(the/usr/local/FFmpeg-n6.0/
folder also has the same contents) -
well since i got the gstreamer backend working i guess ill just give up on ffmpeg for now and use that instead
-
@eramne This is working for me (Ubuntu 20.04), in so much as Qt detects FFmpeg during configuration:
cd /home/martinb/workspace/qt6_local_build/ffmpeg_linux_x86_64_build/FFmpeg-n6.0 /home/martinb/workspace/qt6_local_build/ffmpeg_linux_x86_64_build/FFmpeg-n6.0/configure --disable-programs --disable-doc --disable-debug --enable-network --disable-lzma --enable-pic --prefix=/FFmpeg-n6.0 make make install DESTDIR=/home/martinb/workspace/qt6_local_build/ffmpeg_linux_x86_64_build/FFmpeg-n6.0/installed/FFmpeg-n6.0 /home/martinb/workspace/qt6_local_build/src/qt6/qtbase/configure -top-level -prefix /home/martinb/workspace/qt6_local_build/qt_linux_x86_64_install -static -gstreamer -I /home/martinb/workspace/qt6_local_build/openssl_linux_x86_64_build/openssl-1.1.1s/include -L /home/martinb/workspace/qt6_local_build/openssl_linux_x86_64_build/openssl-1.1.1s -ccache -no-sql-sqlite -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc -no-sql-psql -qt-doubleconversion -qt-libjpeg -qt-libpng -qt-zlib -no-warnings-are-errors -nomake examples -nomake tests -release -openssl-linked -- -DOPENSSL_USE_STATIC_LIBS=ON -DOPENSSL_ROOT_DIR=/home/martinb/workspace/qt6_local_build/openssl_linux_x86_64_build/openssl-1.1.1s -DFFMPEG_DIR=/home/martinb/workspace/qt6_local_build/ffmpeg_linux_x86_64_build/FFmpeg-n6.0/installed/FFmpeg-n6.0
I have a problem further down the line whereby the linker is trying to link the FFmpeg libraries both with and without the lib prefix. I'm currently investigating this.
-
nevermind the gstreamer backend is not working
giving me "Internal data stream error." when i try to play most files, other files it just crashes
back to trying to get the ffmpeg backend to work i guess -
that's weird, since i have all the libav/ffmpeg libraries built and installed at /usr/local/FFmpeg-n6.0, including libavdevice, libavfilter, and libpostproc
this is after running:
./configure -prefix "/home/eramne/Qt6.5.1/" -release -openssl -openssl-linked -no-widgets -submodules qt5compat,qtbase,qtdeclarative,qtimageformats,qtmultimedia,qtshadertools,qtsvg,qttranslations -DFFMPEG_DIR=/usr/local/FFmpeg-n6.0/
-
maybe its just trying to use the ffmpeg packages i have installed via apt instead of the ones i've built and linked to with
-DFFMPEG_DIR=/usr/local/FFmpeg-n6.0/
? If so, how do i stop it from doing that? -
yeah, it's doing that. I tried building/installing ffmpeg 5.1, using the
-DFFMPEG_DIR
thing to point to that, and in the output of the configure script it still showed that it's using the same versions of the av/ffmpeg libraries./configure -prefix "/home/eramne/Qt6.5.1/" -top-level -release -openssl -openssl-linked -no-widgets -submodules qt5compat,qtbase,qtdeclarative,qtimageformats,qtmultimedia,qtshadertools,qtsvg,qttranslations -DFFMPEG_DIR=/home/eramne/Desktop/ffmpeg/installed/ffmpeg-5.1 ./configure -redo
-
i modified the https://github.com/qt/qtmultimedia/blob/6.5.1/cmake/FindFFmpeg.cmake file like this
### Macro: set_component_found # # Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present. # macro(set_component_found _component ) if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS) # message(STATUS " - ${_component} found.") set(${_component}_FOUND TRUE) set(${CMAKE_FIND_PACKAGE_NAME}_${_component}_FOUND TRUE) else () # message(STATUS " - ${_component} not found.") endif () endmacro() find_package(PkgConfig QUIET) #if (NOT PKG_CONFIG_FOUND AND NOT FFMPEG_DIR) # set(FFMPEG_DIR "/usr/local") #endif() set(FFMPEG_DIR "/home/eramne/Desktop/ffmpeg/installed/ffmpeg-6.0")
to explicitly force it to use my own ffmpeg installation
and that worked -
i guess cmake variables are separate from environment variables
since i tried usingexport FFMPEG_DIR=/home/eramne/Desktop/ffmpeg/installed/ffmpeg-6.0
, but that didn't work
i guess i probably could've used the configure.cmake file in some way to set that variable? but i don't use cmake and i don't know how to do that, and i didn't feel like figuring out how -
@eramne You need the -- in the Qt configure line to separate the CMake options from the Qt ones:
./configure -prefix "/home/eramne/Qt6.5.1/" -top-level -release -openssl -openssl-linked -no-widgets -submodules qt5compat,qtbase,qtdeclarative,qtimageformats,qtmultimedia,qtshadertools,qtsvg,qttranslations -- -DFFMPEG_DIR=/home/eramne/Desktop/ffmpeg/installed/ffmpeg-5.1
-
@Martin-Burchell oh! thanks for this
-
@eramne Is it working for you now? I've got a problem linking FFmpeg with static Qt, which I've logged at https://bugreports.qt.io/browse/QTBUG-115052 but if it's working for you, feel free to mark this as Solved