FFmpeg - Undefined symbol: drmModeGetFB2

The undefined symbol: drmModeGetFB2 error can be fixed by compiling FFmpeg yourself.

145 views
d

By. Jacob

Edited: 2021-09-27 05:22

ERROR: ffmpeg: symbol lookup error: /lib/x86_64-linux-gnu/libavdevice.so.58: undefined symbol: drmModeGetFB2

I recently updated to Kubuntu 21.10 beta, and so far everything appears to be working fine; except for FFmpeg, which gave me the above error. To solve the problem I compiled FFmpeg myself from source.

Note. The problem might happen either when you use FFmpeg from the terminal, or when programs such as youtube-dl or yt-dlp is trying to combine downloaded video and audio streams.

Compiling FFmpeg

Compiling FFmpeg might not be easy, since when you try to install dependencies required to compilation, it might complain about some of those needing older versions of other dependencies. I am not sure if those issues are easily fixable, but it looks like you can safely leave out those dependencies, and still compile FFmpeg just fine.

It appears to work so far, so I am happy to use this solution until the official ubuntu repositories are fixed.

1. First you need to install some dependencies required for the compilation:

sudo apt-get update -qq && sudo apt-get -y install autoconf automake build-essential cmake git-core libfreetype6-dev libgnutls28-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 libunistring-dev libaom-dev libdav1d-dev

2. Create the required directories, as recommended in the official documentation:

mkdir -p ~/ffmpeg_sources ~/bin

3. Download the source:

cd ~/ffmpeg_sources && \
wget -O ffmpeg-snapshot.tar.bz2 https://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
tar xjvf ffmpeg-snapshot.tar.bz2 && \
cd ffmpeg

4. The full command I used to compile was like:

PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure --prefix="$HOME/ffmpeg_build" --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" --extra-libs="-lpthread -lm" --ld="g++" --bindir="$HOME/bin" --enable-gpl --enable-libaom --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree && PATH="$HOME/bin:$PATH" make && make install && hash -r

This successfully compiled FFmpeg.

5. Remember to reload the profile:

source ~/.profile

After this, I simply uninstalled the apt version, since it appears that it took precedence before the custom compiled version. I plan on re-installing the apt version once I migrate from 21.10 beta to the final Ubuntu, expected to be released at October 14. Presumably the problem should have been fixed by then.

Using the custom compiled FFmpeg

It appears that you will need to uninstall the FFmpeg that is installed via apt, since it might take precedence, so:

sudo apt remove ffmpeg

The ~/bin/ directory has been added to your path, so you should be able to use programs like yt-dlp without doing anything.

The advantage of the ~/bin/ directory is that it belongs to the current user, and it is totally independent from your package manager. Another option is to place the binaries in /usr/local/bin/ — afaik, the only differences are that they would then take precedence over the binaries installed with apt, and become callable by all users on the system.

Note. These instructions are slightly modified and based on the official FFmpeg compilation guide found here: https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

Problems doing compilation

I had a few problems with unmet dependencies doing compilation, and I am not sure what the proper way to fix those are. This situation is also what some refer to as "dependency hell".

It is probably my own fault, since I prematurely decided to upgrade to a beta version of Kubuntu. Namely 21.10 beta, which might still have bugs.

The way I solved it was simply not to include those libraries when compiling FFmpeg. Here is an example of the error I would get when trying to install libass-dev:

The following packages have unmet dependencies:
libpcre3-dev: Depends: libpcre3 (= 2:8.39-13build3) but 2:8.44-2+ubuntu20.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.

Funny they should name this package "lib-ass" — it sure stinks like ass.

The same thing happened when trying to install libsdl2-dev:

The following packages have unmet dependencies:
libpcre3-dev : Depends: libpcre3 (= 2:8.39-13build3) but 2:8.44-2+ubuntu20.04.1+deb.sury.org+1 is to be installed
E: Unable to correct problems, you have held broken packages.

Anyway, I am not sure how to fix that, so I just tried to compile without, and so far it appears to work. Here is a full list of things I left out from the official documentation:

  • libass-dev
  • libsdl2-dev

Links

  1. Compile FFmpeg for Ubuntu, Debian, or Mint - ffmpeg.org

Tell us what you think:

  1. Sometimes you might want to change the mirror for Ubuntu updates, find out how in this tutorial.
  2. About the problem with using sudo with graphical programs in Linux.
  3. Learn how to remove a repository that fails doing apt update, using the terminal in Ubuntu.
  4. This simple tutorial shows how to solve the problem with duplicated icons created by custom .desktop files.
  5. My experience with do-release-upgrade is that it rarely breaks anything, so I would say it is generally a safe and reliable way to upgrade Ubuntu.

More in: Ubuntu