简体   繁体   中英

Install ffmpeg in to virtual environment

I am trying to install ffmpeg in order to use it on OpenAI to record videos. I have installed it using brew install ffmpeg but somehow when I compile my code I get the same error, it is like the package is not recognized by my virtualenv where I am working.

Error on Python console:

raise error.DependencyNotInstalled("""Found neither the ffmpeg nor avconv executables. On OS X, you can install ffmpeg via `brew install ffmpeg`. On most Ubuntu variants, `sudo apt-get install ffmpeg` should do it. On Ubuntu 14.04, however, you'll need to install avconv with `sudo apt-get install libav-tools`.""")

However, when I execute which ffmpeg I got the following path /usr/local/bin/ffmpeg .

It seems like that Anaconda for example needs a specific command to install this package into its environment, it is the same for virtualenv ?

Thanks in advance.

This is not possible. FFmpeg is a separate application. If you need to use ffmpeg in python, you either need to pip install a wrapper for python (eg ffmpeg-python , ffmpy , etc). But those wrappers does not use the full power of FFmpeg.

Instead what I suggest is to execute command line FFmpeg command in python using subprocess .

Ref:

This is possible. A conda recipe for ffmpeg is available via the menpo or conda-forge channels. Try using this command:

conda create -n newenv -c conda-forge ffmpeg

This question is a little old already, but posting my solution because it could help others.

If you don't use Anaconda (like me) I don't know of a command to install it automatically for you. However, there is a workaround that may work for you.

Go and download the ffmpeg package you desire (eg here ). Then place the ffmpeg.exe executable in the same folder as you python file you are running. Then this part of your code will run and you won't get the error message you described.

This is not literally in your virtualenv . However, it will only be found by files you run from inside that directory. Perhaps this solution is close enough.

Alternatively: If you want it to also work when running python files in other folders, you could extract the entire ffmpeg package to a directory of your choosing. Then add the bin folder containing the executables (among which ffmpeg.exe ) to your PATH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM