FFMPEG: Use In CMake Projects

To add FFMPEG(libav) into CMake project, we can use pkgconfig:

1
2
3
4
5
6
7
8
9
10
11
12
13
find_package(PkgConfig REQUIRED)
pkg_check_modules(FFMPEG REQUIRED IMPORTED_TARGET
libavdevice
libavformat
libavcodec
libavutil
libavfilter
libswresample
libswscale
)

target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE PkgConfig::FFMPEG)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::FFMPEG)

Maybe not all libs are required by your project. Remove unnecessary libs if you want.