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 Index of /ubuntu focal main multiverse restricted universe
deb Index of /ubuntu focal-updates main multiverse restricted universe
deb Index of /ubuntu focal-backports main multiverse restricted universe
deb Index of /ubuntu focal partner
deb Index of /ubuntu focal-security main multiverse restricted universe

# Source-code packages
deb-src Index of /ubuntu focal main multiverse restricted universe
deb-src Index of /ubuntu focal-updates main multiverse restricted universe
deb-src Index of /ubuntu focal-backports main multiverse restricted universe
deb-src Index of /ubuntu focal partner
deb-src Index of /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
    
2 Likes

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 i386 build of ffmpeg 7:4.3-2~18.04.york0 : FFmpeg 4 : Jonathon F 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.

1 Like

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 (c) 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 (c) 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:

I created an account here just to thank you @Yuri for taking the time and outline the steps so thoroughly. Just like the OP I’ve been digging around this problem for hours. Have no idea what installed those “york0” variants, I suspect is some VLC related distro I tried recently.
This backporting business you described is indeed, dare I say, a big pile of sh*t (=mess) and it’s a borderline insanity to deal with for ordinary users. Thanks again!

2 Likes

@tilusnet Hi, I’m glad to hear that this thread helped you, too. :slight_smile: The backporting methodology adopted by the devs indeed becomes very problematic when not all dependencies are satisfied (as was the case above): it puts us in this very uncomfortable circumstance where we have to dig a lot in order to solve something that should be simple, easy and straightforward.

Your reply is much appreciated. Enjoy your fixed system. Happy 2022. :partying_face:

1 Like

Thanks A lot dear Yuri.
I also logged in to this site to thank you.
My problem was:
When I do this command:
sudo apt install ffmpeg -y --reinstall

I saw a long error that contains such this lines:
Depends: libavutil56 (= 7:4.2.2-1ubuntu1) but 7:4.2.4-1ubuntu0.1 is to be installed

Then I run this command that you said:
sudo apt purge libavutil56

After purging all of them, Finally this command worked and ffmpeg installed:
sudo apt install ffmpeg -y --reinstall

And yes the problem was because I installed “VLC” before and that was installed some of ‘libavutil56’ with version uncompatible with ffmpeg

1 Like

@Ehsan_Paknejad Hi. So it seems that your case also involved a hybrid ffmpeg install due to third-party software (VLC, in your case). This is the most frequent case for hybrid installs in the place of distro’s default ones, and indeed is usually solved by purging all the packages and then installing all of them on the same version (and, in more extreme cases, forcing the installation of an specific version). It’s great to know that my previous comments are helping other people like you and @tilusnet. Thanks for letting me know. :grin:

Thank you very much Yuri.
The above command is the correct answer for me.
Linux MInt’s “Update Manager” prompted an update of “LInux Kernel” this week. I did not doubt and installed the update, then it broke my ffmpeg.

Your command remove the newly installed Linux Kernel header and restored everything.

1 Like

@kun_liu Thanks for letting me know. I’m glad that my answer solved this issue for you. :smiley:

Hi, I’m also facing this issue.

When i’m trying to install ffmpeg 5 version
By following this instruction:
sudo add-apt-repository ppa:savoury1/ffmpeg4
sudo add-apt-repository ppa:savoury1/ffmpeg5
sudo apt-get update
sudo apt-get upgrade && sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

Error:
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: libavcodec59 (= 7:5.1.3-0ubuntu1~20.04.sav0)
** Depends: libavdevice59 (= 7:5.1.3-0ubuntu1~20.04.sav0) but it is not going to be installed**
** Depends: libavfilter8 (= 7:5.1.3-0ubuntu1~20.04.sav0)**
** Depends: libavformat59 (= 7:5.1.3-0ubuntu1~20.04.sav0)**
E: Unable to correct problems, you have held broken packages.

Please guide me.

@Umar_Rashid I’m under the impression that you followed the instructions provided by an article like this, but if you take a look at Rob Savoury’s FFmpeg 5 PPA, you’re going to find installation instructions, including this:

*** Install ***

FFmpeg builds here depend on the public FFmpeg PPA (ppa:savoury1/ffmpeg4), and the new private FFmpeg PPA (ppa:savoury1/ffmpeg) for installation. Any who have donated can contact me requesting access to the private PPA. Once you have been granted private PPA access do these steps for installation:

sudo add-apt-repository ppa:savoury1/ffmpeg4
sudo add-apt-repository ppa:savoury1/ffmpeg5
sudo apt-get update
sudo apt-get upgrade && sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

In a nutshell: either donate to Rob Savoury and then contact him to ask access to his private PPA, or remove his ffmpeg4/5 PPAs, purge all previously installed packages and then install the distro-specific ffmpeg v4 that is available in your distro.

To solve unmet dependencies with Ffmpeg:

1:Update your package manager and install missing dependencies.
2:Consider enabling additional repositories or alternative installation methods if needed.