Ubuntu – Error With Shared Libraries: FFMPEG

16.04aptcudaffmpeg

On my fairly old laptop running 16.04, whenever I try to use ffmpeg I get the following error:

$ ffmpeg
ffmpeg: error while loading shared libraries: libcudart.so.5.5: cannot open shared object file: No such file or directory

ffmpeg used to work fine and broke at some point. I can't be sure exactly when, but it might well have been when I upgraded from 14.04 to 16.04.

Running ldd confirms that this library (the CUDA runtime library) is missing, but everything else is fine:

$ ldd /usr/bin/ffmpeg | grep libcudart
libcudart.so.5.5 => not found

I am fairly sure that the file (libcudart5.5) does not exist anywhere on my system (I have tried `find' etc), or indeed any other version of libcudart. The closest thing in the repo to what I need is libcudart7.5, a later version. But this comes along with an nvidia driver upgrade (nvidia-367) as a dependency which I have found several times now tanks the whole system (due to the graphics card being a bit out of date I think).

So basically I'm confused as to why ffmpeg is trying to link to libcudart5.5 in the first place. Surely it should be possible to run ffmpeg without needing GPU support? In fact I know it is because on another computer I use running 16.04, ldd shows no dependency on any version of libcudart and ffmpeg works just fine. The version of the ffmpeg package is the same in both cases:

$ dpkg -s ffmpeg | grep Version
Version: 7:2.8.11-0ubuntu0.16.04.1

So why is it looking for it on my laptop? I have tried purging ffmpeg and reinstalling it several times with no luck. One thing that seems relevant was that I found a residual-config entry for a package called libcudart5.5 installed on my system. I don't really know what this means, but after removing it and reinstalling ffmpeg, it didn't make a difference. It might also be relevant that at one stage (under 14.04) I had the full CUDA sdk installed, but then completely removed it and don't want to reinstall it.

I'd really appreciate any help because I'd really like to use ffmpeg on my laptop for video conversion and this has been bugging me for a while now.

Thanks!

Best Answer

I'm answering my own question after some investigation inspired by ridgy's comment on the original question (thanks!). I began exploring whether some other library used by ffmpeg had libcudart as a dependency. The lddtree tool from the package pax-utils is really helpful for this as it gives you a hierarchical list of the linker dependencies rather than a flat list. E.g.

$ lddtree /usr/bin/ffmpeg

Using this, I discovered that libcudart.so.5.5 was a linker dependency of libopencv_core.so.2.4 which was left lying around in /usr/local/lib from a while back when I compiled OpenCV 2.4 from source and never cleaned up when the new version (version 3.0) came along.

To fix this, I uninstalled ffmpeg and all opencv packages using apt, then manually deleted the leftover opencv 2.4 files in /usr/local/lib using

$ sudo rm /usr/local/lib/libopencv_*.so.2.4*

Then reinstalled ffmpeg from the repo and now all is well.

This seems like a fairly specific set of circumstances that might not be that relevant to others, but perhaps this answer can be useful to others with similar problems.

Related Question