Fix ffmpeg: error while loading shared libraries: libavdevice.so.59: cannot open shared object file: No such file or directory – Linux Tutorial

By | August 31, 2022

When we are using python subprocess to call ffmpeg, we ge this error: ffmpeg: error while loading shared libraries: libavdevice.so.59: cannot open shared object file: No such file or directory. In this tutorial, we will introduce you how to fix it.

The python example code is here:

try:
    out = subprocess.call('ffmpeg -y -i %s -ac 1 -vn -acodec pcm_s16le -ar 16000 %s >/dev/null 2>/dev/null' %(fname,outfile), shell=True)
    num += 1
except Exception as e:
    print(e)

In order to understand how to use python subprocess, you can read:

Implement Python subprocess.Popen(): Execute an External Command and Get Output

Run the code above, we will see:

ffmpeg: error while loading shared libraries: libavdevice.so.59: cannot open shared object file: No such file or directory

How to fix this loading error?

We can use this solution.

Step 1: edit ld.so.conf file

vim /etc/ld.so.conf

Then we can add content below in this file:

include ld.so.conf.d/*.conf
/usr/lib
/usr/local/lib

Then save it.

Step: Run command below

ldconfig

Then this error will be fixed.

fix FFmpeg libavdevice error

Leave a Reply