TL;DR
Export the required library, run:
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64/:/usr/local/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
ffmpeg: error while loading shared libraries: libavdevice.so.58
The Background.
Last year, I had a lot of fun testing the new Intel Flex Series GPUs (formerly codenamed Arctic Sound-M). In particular, I was playing around with the Flex Series 140, for Media Delivery and Transcoding solutions, using FFmpeg. The environment: Ubuntu 20.04.
It is important to mention, that I am using some kind of special version from Intel, however, I found this error common in FFmpeg.
The Problem.
After installing FFmpeg and running it, (ffmpeg or ffmpeg -version), you receive the following error message:
"ffmpeg: error while loading shared libraries: libavdevice.so.58: cannot open shared object file: No such file or directory”
The cause of this issue is that FFmpeg is unable to load a required shared library file, libavdevice.so.58. And that Ubuntu has not configured the environment variables through the source code installation software; as a result, the startup path cannot be found.
Here are some options you can take to resolve this error on Ubuntu:
Export the required FFmpeg library
Open a terminal window. Run the following command to export the required library to the right path.
export LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib64/:/usr/local/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
Try running the FFmpeg command again to confirm that the error has been resolved:
ffmpeg
If FFmpeg runs without error, like in the below image, then the issue has been resolved. If not, you may need to try the fix below.
Configure FFmpeg environment variables
In the Ubuntu terminal, run:
sudo vim /etc/ld.so.conf
Note: This is the default installation path for FFmpeg. If the path is different, you will need to switch to your own installation path and then point to the "lib" folder.
After opening the (VIM) text editor, add the following line.
/usr/local/ffmpeg/lib/
Save the file and run:
sudo ldconfig
You're done! Type ffmpeg again to check.
ffmpeg