Ffmpeg solve unmet dependencies

Trying to install ffmpeg on Ubuntu 20.04 LTS but unsuccessful as I have unmet dependencies and been trying to google my way to solve it. But too much a newbie to fix it

I followed this the guide on ffmpeg installation on this site, but I did try to compile.

When running
sudo apt install ffmpeg
I get the below output, what would be best course of action to identify the problem and solve it?

Reading package lists… Done
Building dependency tree
Reading state information… Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
ffmpeg : Depends: libavcodec58 (= 7:4.2.4-1ubuntu0.1)
Depends: libavdevice58 (= 7:4.2.4-1ubuntu0.1) but it is not going to be installed
Depends: libavfilter7 (= 7:4.2.4-1ubuntu0.1)
Depends: libavformat58 (= 7:4.2.4-1ubuntu0.1) but 7:4.3-2~18.04.york0 is to be installed
Depends: libavresample4 (= 7:4.2.4-1ubuntu0.1) but it is not going to be installed
Depends: libavutil56 (= 7:4.2.4-1ubuntu0.1) but 7:4.3-2~18.04.york0 is to be installed
Depends: libpostproc55 (= 7:4.2.4-1ubuntu0.1) but 7:4.3-2~18.04.york0 is to be installed
Depends: libswresample3 (= 7:4.2.4-1ubuntu0.1) but 7:4.3-2~18.04.york0 is to be installed
Depends: libswscale5 (= 7:4.2.4-1ubuntu0.1) but 7:4.3-2~18.04.york0 is to be installed
E: Unable to correct problems, you have held broken packages.

Running;
Distributor ID: Ubuntu
Description: Ubuntu 20.04.1 LTS
Release: 20.04
Codename: focal

Press Ctrl Alt T to start a new shell terminal emulator window, then select and copy this very long command:

sudo apt-get clean ; sudo apt-get update ; sudo apt-get check ; sudo apt-get purge ffmpeg* -y ; sudo apt-get autoremove -y ; sudo apt-get -f satisfy ffmpeg -y

Once you’ve copied the command above, return to the shell terminal window, press CtrlShiftV to paste such command and then press Enter to run it.

Description of the command above:

  • clean instructs APT to clean the cache of repositories so any misconfigured list of packages or damaged DEB package is deleted from the local drive and must be downloaded again.
  • update updates such cache, thus downloading a new list of repositories. DEB packages will only be downloaded again if you (re)install any again.
  • check makes sure that such new cache’s structure is ok.
  • purge ffmpeg* -y completely removes ffmpeg.
  • autoremove -y removes packages that were previously installed only because they were ffmpeg’s dependencies.
  • -f satisfy ffmpeg -y fixes broken packages and installations (if any is yet left to fix) and then installs ffmpeg while forcing the system to satisfy all such package’s dependencies.

If the problem persists, maybe you added some PPA repository that provides newer but broken packages. Try this:

  1. Run this command in order to backup your original sources.list file:

    sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak
    
  2. Install GEdit text editor:

    sudo apt install gedit -y
    
  3. Use GEdit to create a new sources.list file:

    sudo gedit /etc/apt/sources.list
    
  4. Select and copy this code:

# Application packages
deb http://archive.ubuntu.com/ubuntu focal main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu focal-updates main multiverse restricted universe
deb http://archive.ubuntu.com/ubuntu focal-backports main multiverse restricted universe
deb http://archive.canonical.com/ubuntu/ focal partner
deb http://security.ubuntu.com/ubuntu/ focal-security main multiverse restricted universe

# Source-code packages
deb-src http://archive.ubuntu.com/ubuntu focal main multiverse restricted universe
deb-src http://archive.ubuntu.com/ubuntu focal-updates main multiverse restricted universe
deb-src http://archive.ubuntu.com/ubuntu focal-backports main multiverse restricted universe
deb-src http://archive.canonical.com/ubuntu/ focal partner
deb-src http://archive.ubuntu.com/ubuntu focal-security main multiverse restricted universe

  1. Paste the code above in GEdit’s window (your new sources.list file), then save the file (Ctrl S) and exit GEdit.

  2. Execute the very long command once again:

    sudo apt-get clean ; sudo apt-get update ; sudo apt-get check ; sudo apt-get purge ffmpeg* -y ; sudo apt-get autoremove -y ; sudo apt-get -f satisfy ffmpeg -y

Thanks Yuri for your kind attempt. Unfortunately I was stuck after the first attempt and also after following your second remedy instruction. Problem with unmet dependencies seems to persist.

And it seems I don’t get the complete and entire error message - this is what it ends with the below;


Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
command line argument : Depends: ffmpeg but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Is it best to roll-back the backup of sources to something that points to older but not broken packages?
What other remedies might there be to attempt new fixes to this or am I facing a new install of ubuntu server to get around this issue?

It seems that the source repository for the york0 packages is the problem in your system. Please post here the output of this command:

egrep -v '^#|^ *$' /etc/apt/sources.list /etc/apt/sources.list.d/*

Also install ppa-purge because you’ll likely have to use it in order to remove the problematic ppa:

sudo apt install ppa-purge

Your help is appreciated :slight_smile:
ppa-purge installed

Output (not able to post link, hence the picture):
egrep -v '^#|^ *’ /etc/apt/sources.list /etc/apt/sources.list.d/*

@Motvind No problem, you’re welcome. :slight_smile:

I forgot to mention that none of the commands executed in the terminal should be executed as root (admin / superuser), but as yourself. E.g. if you run this command in the shell:

whoami

…the output must be the name of your account in the Linux system, instead of root. If you happen to run whoami and the output is root, check what is your username (e.g. motvind) and then run su username (e.g. su motvind) in order to connect your regular user account to the Linux shell. All the shell commands below presume that you’re connected to the shell as a regular user instead of root.


I happen to be running XUbuntu 20.04 and have ffpmeg installed. However, in my case these are the DEB packages that were actually installed after I ran sudo apt install ffmpeg -y:

  • ffmpeg version 7:4.2.4-1ubuntu0.1
  • libavcodec58 version 7:4.2.4-1ubuntu0.1
  • libavdevice58 version 7:4.2.4-1ubuntu0.1
  • libavfilter7 version 7:4.2.4-1ubuntu0.1
  • libavformat58 version 7:4.2.4-1ubuntu0.1
  • libavresample4 version 7:4.2.4-1ubuntu0.1
  • libavutil56 version 7:4.2.4-1ubuntu0.1
  • libpostproc55 version 7:4.2.4-1ubuntu0.1
  • libswresample3 version 7:4.2.4-1ubuntu0.1
  • libswscale5 version 7:4.2.4-1ubuntu0.1

Notice that all these packages are of the exactly same version 7:4.2.4.

However, when you run sudo apt install ffmpeg -y, even though your system attempts to install ffmpeg version 7:4.2.4-1ubuntu0.1 it simultaneously attempts to install libavformat58 etc. version 7:4.3-2~18.04.york0, which is a more recent version (7:4.3-2 is greater than 7:4.2.4), it’s a set of packages designed for Ubuntu version 18.04 instead of Ubuntu 20.04 (it’s called a backport i.e. a newer application version that is however provided for a previous Ubuntu release like e.g. 18.04), and that york0 indicates that each of these packages is a modified release of version 7:4.3-2 (i.e. 7:4.3-2-ubuntu0.1 would be the official release of version 7:4.3-2 for Ubuntu 20.04, but then someone modified such package in order to make it compatible with Ubuntu 18.04 and then called it 7:4.3-2~18.04.york0 which means york0 backport modification of version 7:4.3-2 designed for Ubuntu 18.04).

So the problem here seems to be that your system found a newer version (7:4.3-2) of some (not all) of these DEB packages in repository X (which does not provide Ubuntu 20.04 packages: only 18.04 backports), and because APT did not find all required DEB packages version 7:4.3-2 in repository X, APT simultaneously attempted to install the remaining DEB packages (version 7:4.2.4) from Ubuntu’s official repository, thus causing APT to attempt a “mixed versions” (hybrid) installation of 7:4.2.4 DEBs along with 7:4.3-2 DEBs. What a mess! :crazy_face:

Because this would break the entire ffmpeg installation (these versions 7:4.2.4 and 7:4.3-2 conflict with each other: they’re not compatible), APT prevents the installation from proceeding. :pray:t2:

So APT searches such DEBs first in repository X because repository X provides the more up-to-date DEBs (version 7:4.3-2). However, because APT does not find all the required DEBs in such repository even though it should (the repository X is the one to blame here), APT ends up trying to fix this problem by getting the missing DEBs from Ubuntu’s official repository, even though the official repository only provides an older version (7:4.2.4), which is not compatible with the more up-to-date one (7:4.3-2).

:point_right: Because repository X does not provide all required DEBs, it’s recommended to purge (remove) repository X from your system and then install everything from the official repository.

The list of Ubuntu’s official repositories of DEB packages is stored in /etc/apt/sources.list (i.e. the list of official repositories is recorded in the sources.list file stored at /etc/apt/). In order to make sure that your sources.list file contains only official Ubuntu 20.04 repositories, I asked you to backup your original file (i.e. rename it to sources.list.bak) and then create a new (substitute) sources.list file containing the list of official Ubuntu 20.04 repositories. This new list that you previously created is exactly the same one that’s in my own /etc/apt/sources.list file in my system: both our systems are version 20.04, so this list serves us both. :handshake:

Strangely, though, you were still unable to fix your broken DEBs after you created a “cleaned up” and reliable sources.list file. This means that repository X is listed somewhere else: in /etc/apt/sources.list.d/. The lists of extra (additional) repositories are stored at /etc/apt/sources.list.d/ (i.e. the directory sources.list.d in /etc/apt/), so repository X has to be a some-name.list file stored at /etc/apt/sources.list.d/. I Googled 7:4.3-2~18.04.york0 and found it in the https://launchpad.net/~jonathonf/+archive/ubuntu/ffmpeg-4/+build/19472264 repository, which led me to think that either you or someone with root (administrative) privileges to your Ubuntu 20.04 system added such repository to your system by running a command such as this one:

sudo add-apt-repository ppa:jonathonf/ffmpeg-4

Hence, ppa:jonathonf/ffmpeg-4 seems to be the misterious repository X.

I added such PPA to my system just to test it. Afterwards, in order to purge such PPA repository, I ran this command:

sudo ppa-purge -p ffmpeg-4 -o jonathonf

However, the command above did not work. Hence, ppa-purge apparently does not work in Ubuntu 20.04 and must be uninstalled by running this command:

sudo apt purge ppa-purge -y

I eventually managed to remove that PPA by running this command:

sudo add-apt-repository ppa:jonathonf/ffmpeg-4 -r

That -r tells APT that it must remove the PPA repository instead of adding it.

Because you have those *york0 DEBs installed, I expected that egrep command to provide an output containing this:

/etc/apt/sources.list.d/jonathonf-ubuntu-ffmpeg-4-focal.list: deb http://ppa.launchpad.net/jonathonf/ffmpeg-4/ubuntu focal main

This would mean that a file jonathonf-ubuntu-ffmpeg-4-focal.list would be located at /etc/apt/sources.list.d/. However, the egrep output from your system did not return such information, which is weird. :face_with_raised_eyebrow: I did not expect this!

Anyway… Just in case, please run:

sudo add-apt-repository ppa:jonathonf/ffmpeg-4 -r

…just to tell your system to purge such PPA anyway.

Please also run these commands:

  • Remove any Jonathon F repository list file(s) that eventually still exist at /etc/apt/sources.list.d/:

    sudo rm /etc/apt/sources.list.d/jonathonf*
    
  • Also remove any Jonathon F repository list subdirectory that eventually exist at /etc/apt/sources.list.d/:

    sudo rmdir /etc/apt/sources.list.d/jonathonf*
    
  • Remove Jonathon F’s 1st PPA signing key (it serves to authenticate the Jonathon’s repository of application packages):

    sudo apt-key del 3ADCA79D
    
  • Remove Jonathon F’s 2nd PPA signing key (it serves to authenticate the Jonathon’s repository of source-code packages):

    sudo apt-key del F06FC659
    

All these steps are intended to make sure that Jonathon F’s PPA repository (i.e. repository X and all its signing keys) is completely deleted from your system.

If you get errors, don’t worry, just keep going (run the subsequent commands anyway).

Based on your provided image, I’ve also checked if either the svtplay-dl or the plex.tv repository provides a 7:4.3-2 york0 version of ffmpeg or one of its dependencies, but no, they do not, they’re not involved in this.

So now you should run:

sudo apt clean ; sudo apt update

…and then reinstall ffmpeg normally:

sudo apt install ffmpeg -y --reinstall

If the installation is still damaged, maybe it’s because APT is holding DEB packages in your system even though such DEBs are version 7:4.3-2 york0, which is not compatible with the other DEBs in your system. So the next attempt here is to purge each one of the problematic DEB packages. Please run each one of these commands separately, in this exact order:

  • sudo apt purge libswscale5 -y
    
  • sudo apt purge libswresample3 -y
    
  • sudo apt purge libpostproc55 -y
    
  • sudo apt purge libavutil56 -y
    
  • sudo apt purge libavresample4 -y
    
  • sudo apt purge libavformat58 -y
    
  • sudo apt purge libavfilter7 -y
    
  • sudo apt purge libavdevice58 -y
    
  • sudo apt purge libavcodec58 -y
    
  • sudo apt purge ffmpeg -y
    

Ignore errors, because some of these DEBs may be not installed.

Once you’ve purged ffmpeg’s DEB package and all its dependency DEB packages, clean up and rebuild the APT cache once more:

sudo apt clean ; sudo apt update

Check if no error is output. If any error is output, please report it here.

If no error was output, then check if there’s anything broken left to fix:

sudo apt -f install

If the above command returns any error, please report it here. But if no error is output, then perform a system upgrade just in case:

sudo apt dist-upgrade -y

Once the system is upgraded, cross fingers :crossed_fingers:t2: and then run ffmpeg’s installation command once again:

sudo apt install ffmpeg -y

If you get the very same errors as before, try forcing all these packages to the default version 7:4.2.4-1ubuntu0.1. This very long command instructs the shell to perform such task:

for i in libswscale5 libswresample3 libpostproc55 libavutil56 libavresample4 libavformat58 libavfilter7 libavdevice58 libavcodec58 ffmpeg ; do sudo apt install $i=7:4.2.4-1ubuntu0.1 -y --reinstall ; done

If you succeed in installing ffmpeg, check its version by running this command:

ffmpeg -version |grep -i "ffmpeg version"

…but if none of the above instructions worked, your system likely has a deeper issue that right now I’m unable to fathom. Anyway, in such case I recommend installing Synaptic (windowed DEB package manager) and Xapian (it creates a search database and search field inside of Synaptic’s interface):

sudo apt install synaptic apt-xapian-index -y ; sudo update-apt-xapian-index

Once you’ve installed both Synaptic and Xapian, start Synaptic from the Applications menu or straight from the shell by running this command:

pkexec synaptic

Once you’re at Synaptic’s interface, you may want to access Settings :arrow_right: Preferences :arrow_right: Distribution :arrow_right: Prefer versions from, select focal-updates and click on OK, then click on Reload (a.k.a. Refresh). If you experience problems with this, try changing focal-updates to focal (a last resource is stable). Synaptic also makes it easier to search, find, select and deselect packages that you either wish to install or uninstall.

I had to go all the way down here to have the issue resolved.
Now ffmpeg (and svtplay-dl) work as expected. Such a brilliant mind Yuri.

However, when running
$ ffmpeg -version |grep -i “ffmpeg version”

I get the following output;
Error: unable to open display
ffmpeg version n4.3.1 Copyright © 2000-2020 the FFmpeg developers

so although ffmpeg seems to work, at least in conjuction with svtplay-dl there still seems to be some issue with the install. But at this point in time I am so glad you were able to both identify and help me solve it.

When I google the output, I find similar problems but all have a digit at the end of the “Error-line” indicating some kind of specific issue

1 Like

@Motvind I’m happy for you as you managed to get ffmpeg to work. It’s a great step forward, indeed. :partying_face:

It’s unlikely that the output error message concerning ffmpeg -version is related to typo or localization error, still I can’t help but notice that those double quotes that you posted look slightly different from the " ones that I had posted, thus I keep wondering if by eliminating such characters from that command the output issue would cease to happen.

Well, it’s possible to run ffmpeg -version |grep -i "ffmpeg version" without double quotes. This is how:

ffmpeg -version |grep -i ffmpeg\ version

The \ character tells the shell that it must treat the blank space character between ffmpeg and version as part of a single (long) string of characters, i.e. ffmpeg version must be parsed (interpreted) by the shell as if it’s a “single word” instead of a word followed by a separator (blank space) followed by another word (think of the blank space character as just another letter or number etc., e.g. just like the - causes ffmpeg-version to look as a single sequence of characters, the shell can be instructed to do the same about the blank space character). This eliminates the need to put the entire sentence between double quotes: just like putting ffmpeg version between double quotes causes the shell to look at ffmpeg version as a single string, \ turns the blank space character into a regular character (instead of a special one) and therefore the shell parses ffmpeg\ version exactly the same way that it parses "ffmpeg version".

Anyway, if you run ffmpeg -version |grep -i ffmpeg\ version and still get the same error, there’s something wrong concerning your display, the DISPLAY environment variable and the X.org server.

@Motvind Let’s make some tests. Run this command and see if it works:

ffmpeg -f x11grab -video_size cif -framerate 25 -t 5 -i :0 /tmp/out.mpg

If it does work (i.e. no error message is shown and the out.mpg file is successfully created at /tmp/, thus allowing you to play it by runing e.g. parole /tmp/out.mpg), then :0 is the correct display where the X server is available (applications connect to display :0 in order to access the X server’s graphical interface functionalities). If so, run this command in order to export such correct information to your personal shell configuration file:

echo export DISPLAY=:0 |tee -a ~/.bashrc

If however that command does not work, try this one:

ffmpeg -f x11grab -video_size cif -framerate 25 -t 5 -i :1 /tmp/out.mpg

If this alternative command does work (i.e. no error message is shown and the out.mpg file is successfully created at /tmp/, thus allowing you to play it by runing e.g. parole /tmp/out.mpg), then :1 is the actually correct display where the X server is available. If so, run this command in order to export such correct information to your personal shell configuration file:

echo export DISPLAY=:1 |tee -a ~/.bashrc

It is unlikely that a display :2 exists in your system. Hence, attempting the above commands with :0 and :1 will likely suffice.

If you made some mistake and want to edit your .bashrc file, use GEdit:

gedit ~/.bashrc

If you modified your .bashrc file, it is necessary to reboot the system so such changes can take effect. Here are some restart/reboot commands:

sudo init 6

or

reboot

or

sudo telinit 6

or

sudo shutdown -r now

If the modification in your .bashrc file worked, then, after the reboot, a command such as echo $DISPLAY must return :0 or :1 (depending on which one you stored in your .bashrc file). Also, ffmpeg -version must not return that unable to open display error message anymore.

The above did indeed output without errors, starting to realize the output error with ffmpeg is related to the fact that no display is connected to the server as I am running it as headless

output:
ffmpeg version 4.2.4-1ubuntu0.1 Copyright © 2000-2020 the FFmpeg developers

Again Yuri, you helped me solve something I after several hours googling thought be impossible to rectify. Much appreciated :slight_smile:

1 Like

Awesome. I’m glad to hear that my suggestions helped you. Enjoy your system with ffmpeg. :slight_smile: :+1: