Recently, there is a small task that needs audio transcoding, which needs to be used ffmpeg, There are many problems encountered in the process of installation and use, and there is no way to solve them , It’s hard to find all kinds of tutorials from the Internet , The second brother of this article will sort out from 0 To 1 stay Mac Upper use ffmpeg.
The first step is to install… In the system ffmpeg, Many people have given the use of
brew Command to download , Let’s talk about it here , The majority of people
brew I have to wait after n minute , Finally, it ended up reporting an error , This kind of external website is unstable , Therefore, this method is strongly not recommended .
Stable installation method
First step ： Go to the official website to download the installation package ：ffmpeg Official website
The second step ： Choose your own system , Click the place in the picture ：
The third step ： Find a version to download （ffprobe etc. ） Empathy
Step four ： Decompress the downloaded compressed package to get FFmpeg（ Just get the following ）
- After decompression
ffmpegThe program will be left directly in the directory at the time of download , At this time, we find the specified location and create the parent folder
ffmpeg, A folder
bin, And then ffmpeg The program moves to
The example path is as follows （ final ffmpeg It’s the program ！ Anywhere ）：
- Next, remember this path , Configure environment variables , Open the terminal , Input ：
Then put the following code inside （ Change the path to your own ）
The effect of placing is as follows ：
Save the file, exit and execute the following code on the terminal （ Used to activate the profile ）：
After execution , Input :
The following results can be obtained ：
Now your terminal can be used ffmpeg 了 .
Don’t be reckless when installing ！ Don’t directly
pip install ffmpeg
To use the package correctly, we need to install
The correct command is ：
pip install ffmpeg-python
Once installed , Some simple function calls have been successful , But most people will encounter
ffmpeg.run() Problems that cannot be used , This is a core function , So we need to modify the configuration file .
- find site-package Under folder ffmpeg（ The approximate path is as follows ）
_run.pyFile and open .
- Pull down , In about 292 That’s ok , Modify your path according to the style in the figure below and save it .
Other functions that cannot be used （ Tools ） You can also follow this operation .
So far, we have finished , Happily in Python Use it in , If you encounter other errors, you can leave a message below , If you solve your problem, just praise it ！！
Read more here: Source link