FFmpeg installation and configuration (windows and mac)

FFmpeg command line installation

Use the following command to run FFmpeg:

sudo apt-get install ffmpeg

FFmpeg source code installation

Obtain FFmpeg source code

Use the following command to obtain the source code of ffmpeg:

git clone  https://git.ffmpeg.org/ffmpeg.git ffmpeg

ubuntu screenshot

mac screenshot

ffmpeg compile

Use the following command to specify the installation directory:

./configure --prefix=/usr/local/ffmpeg --enable-debug=3 --enable-shared --disable-static --disable-x86asm

Use the prefix parameter to specify the installation directory, which is usually installed in the local /usr/local directory.

Since there will be a need to debug the source code in the future, turn on the debug mode and set –enable-debug to 3.

This command will turn off static library generation and turn on dynamic library generation.

Finally, x86asm will be closed, which is a must-do under both Ubuntu and Mac.

mac screenshot:

I recently installed ffmpeg on mac and found that this parameter –disable-x86asm is also required, and a warning appeared during the installation process, as shown in the picture above. However, practice has proved that you don’t need to pay attention to it for the time being, and you can just continue compiling in the next step.

A new Makefile will be generated at this time.

Open the configure file to view. In essence, the prefix parameter is passed in an installation directory, as shown in the figure below.

The four file paths circled here, bin , share , lib , and include , are the main paths to generate products after the installation is completed, which will be explained again below.

Use the following command to view all ffmpeg compilation parameters:

./configure --help

Use the following command to compile ffmpeg:

make -j 4

This command will call 4 cores for parallel compilation, which can greatly improve the compilation speed.

Use the following command to install:

make install

mac screenshot:

Solve the problem that there is no ffplay after compilation

Install SDL dependencies

Since the ffmpeg version I installed is 4.4, the sdl1.2 circulating on the Internet has no effect, so use the following command to install SDL2.

sudo apt-get install libsdl2-dev

Only after installing SDL can ffplay be compiled, but besides installing SDL, there are other things that need to be dealt with.

When installing sdl2 on the terminal under mac, you need to use brew. apt-get is the package management tool under ubuntu, and brew is the package management tool under mac.
Mine does not have brew by default, so you need to install it yourself:

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"

Select the serial number from the University of Science and Technology of China. The solution comes from this blog: link

Use brew to view sdl2 information

brew search sdl2

mac screenshot:

Use brew to install sdl:

brew install sdl2

Change config.h file

Open the config.h file in the ffmpeg root directory, search for CONFIG_FFPLAY so that its value is 1, and then search for CONFIG_ALSA so that its value is 1. This is the function of turning on ffplay and alsa at compile time.

Change the config.mak file

In the config.mak file in the build directory under the ffmpeg directory, search for CONFIG_FFPLAY and set its value to yes, search for CONFIG_ALSA and set its value to 1

For the config.mak file in the ffbuild directory under mac, search for CONFIG_FFPLAY and set its value to yes

Recompile ffmpeg

Recompile after modifying the above steps.

mac screenshot:

Introduction to FFmpeg

Introduction

After completing the installation of ffmpeg, go to /usr/local/ffepeg to view:

You can see that after the ffmpeg installation is completed, the four paths mentioned above are mainly generated.

bin: stores all ffmpeg command tools

include: stores all header files of ffmpeg

lib: stores the dynamic library or static library generated by ffmpeg

share: stores ffmpeg related documents and examples

bin directory

There are three command tools in the bin directory, namely ffmpeg, ffplay, and ffprode.

ffmpeg: can perform push streaming, audio and video processing

ffplay: a player that can stream and play local audio and video files

ffprobe: used to detect multimedia files, such as some formats and basic information

There may be a few less tools when compiling, for example mine was missing ffplay at the beginning

include directory

Enter the include file to store all ffmpeg header files. Later, when using the header files for secondary development of ffmpeg, enter this directory to search. Each subdirectory is a module.

libavcodec: codec

libavdevice: management device

libavfilter: various filter effects and special effects

libavformat: multimedia format processing

libavutil: some basic tools

libswresample: audio resampling

libswscale: video scaling and other processing

lib directory

Enter the lib file to store all generated ffmpeg dynamic libraries/static libraries.

Taking libavcodec as an example, libavcodec.so.59.0.100 is the real library, and the other two libavcodec.so.59 and libavcodec.so are connectors. Use them according to your own preferences.

If used on the mobile terminal, a total static file (a file) can also be generated.

share directory

Enter the share directory, there are mainly some ffmpeg documents, such as man documents.

Under Linux, you can use the following command to view the man manual:

man ls

Configure FFmpeg environment

After installation, you cannot run ffmpeg directly from the command line unless you cd into its bin path. This is because there is no ffmpeg path in the system.

ubuntu processing

At this time, you need to add ffmpeg to the system environment.

Open the system PATH file using the following command:

sudo gedit /etc/profile

After opening the file, add the following statement at the end of the file:

export PATH=$PATH:/usr/local/ffmpeg/bin

After saving and exiting, use the following command to make it effective immediately:

source /etc/profile

At this time, use the following command to check whether ffmpeg is installed successfully:

ffmpeg --help

The following error occurs:

At this time, it is because the dynamic libraries generated by compilation have not been included in the system, so the display cannot be found. Since the generated dynamic libraries are in the /usr/local/ffmpeg/lib directory, this directory must be placed in the system. in environment.

Use the following command to open the relevant file:

gedit /etc/ld.so.conf

This file is blank under Mac. I don’t know if it is vacuum white or if it does not exist in the first place and was created after running the command, but it is not important.

Add the following statement on a new line in this file:

/usr/local/ffmpeg/lib

Among them, /usr/local/ffmpeg is the location where it was just installed.

Finally use the command:

sudo ldconfig

By typing ffmpeg in the terminal, if the relevant version information is obtained, the configuration is successful.

mac processing

Under Mac, gedit should not be installed by default, so use the following command to install it:

brew install gedit

But it prompts an error:

Error: [email protected]: the bottle needs the Apple Command Line Tools to be installed.

You can install them, if desired, with:

xcode-select --install

You can try to install from source with:

brew install --build-from-source [email protected]

I thought it required a python environment, but without looking carefully, I installed python3.8 because I personally prefer 3.8, but I still had this problem, and then I realized that it was a lack of environment.

Enter the following command in the terminal to install:

xcode-select --install

Press Enter to pop up the app store small window for installation. After the installation is complete, enter the command to install gedit:

brew install gedit    

Open the configuration file using the command:

sudo gedit ~/.bash_profile

Add this statement at the end, which is the bin directory of ffmpeg:

export PATH=$PATH:/usr/local/ffmpeg/bin

Then save and exit.

Then execute the following command to make the newly configured environment variables take effect:

source ~/.bash_profile

Then enter the following command to test whether ffmpeg is successfully added to the system environment:

ffmpeg

mac screenshot:

2021.6.26 Update

After installing ffmpeg in the mac environment, I will sort out the points found:

1. During configuration, the command parameter –disable-x86asm is required.

2. You will encounter a warning after executing the configuration command:

WARNING: pkg-config not found, library detection may fail.

But you can ignore it for the time being, and it will not affect the compilation and installation of ffmpeg.

3. After installation, it is found that there is still no ffplay and there is no ffmpeg in the system environment. That is, ffmpeg cannot be found by directly typing in the terminal. It is also necessary to add the installed bin path to the system and process it like Ubuntu. The same goes for ffplay.

4. When adding some compiled ffmpeg tools (bin directory) to the system environment, because mac does not have gedit, and the configuration is slightly different, I updated how to install gedit and update the configuration file, but if you are used to using You can also use vim without installing gedit.

5. Note: All commands for mac that are not specifically marked in the article are universal, that is, the same commands are used on both ubuntu and mac platforms. In fact, there are slight differences when installing some software, because mac uses brew and ubuntu. Using apt-get, the rest is basically the same.

Original link: FFmpeg installation and configuration (windows and mac)_Yiye Zhiqiu@qqy's blog-CSDN blog

★The business card at the end of the article allows you to receive free audio and video development learning materials, including (FFmpeg, webRTC, rtmp, hls, rtsp, ffplay, srs) and audio and video learning roadmap, etc.

See below! ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

 

Guess you like

Origin blog.csdn.net/yinshipin007/article/details/130567679
Recommended