I'm trying to follow a tutorial about using the FFMpeg libraries to extract frames from videos in C++ (by Bartholomew).
In order to include the libraries, according to the tutorial, it is advised to use pkg-config to find the libraries and put them together so that CMake can include them. In the video he uses homebrew to install ffmpeg and somehow pkg-config is able to find the header files for ffmpeg (libavcodec, libavformat, libavdevice ...)
The problem is I don't know how to get the ffmpeg libraries installed so that pkg-config can find them.
On windows, I've tried installing the compiled windows binaries, and I've tried installing ffmpeg-full package using chocolatey. However, I fail to see where these header files are installed to.
There's a ffmpeg folder in C:/ffmpeg/ but when I look in that there's no header files or libraries, just the binaries. Perhaps I need to clone the entire source project, but then how is pkg-config supposed to find them? When I try and compile I get this output:
Found PkgConfig: C:/Strawberry/perl/bin/pkg-config.bat (found version "0.26")
Checking for module 'libavcodec'
Can't find libavcodec.pc in any of C:/Strawberry/c/lib/pkgconfig
use the PKG_CONFIG_PATH environment variable, or
specify extra search paths via 'search_paths'
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPkgConfig.cmake:607 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/FindPkgConfig.cmake:829 (_pkg_check_modules_internal)
lib/FFMpeg/CMakeLists.txt:5 (pkg_check_modules)
Checking for module 'libavcodec' <----- here
Can't find libavcodec.pc in any of C:/Strawberry/c/lib/pkgconfig
use the PKG_CONFIG_PATH environment variable, or
specify extra search paths via 'search_paths'
CMake Error at C:/Program Files/CMake/share/cmake-3.24/Modules/FindPkgConfig.cmake:607 (message):
A required package was not found
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.24/Modules/FindPkgConfig.cmake:829 (_pkg_check_modules_internal)
lib/FFMpeg/CMakeLists.txt:5 (pkg_check_modules)
The contents of C:/Strawberry/c/lib/pkgconfig seem to be a whole load of libraries none of which are from ffmpeg.
In case the problem is in my CMakeLists file, here are the contents of the subdirectory file:
cmake_minimum_required(VERSION 3.9)
project(FFMpeg)
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVCODEC REQUIRED IMPORTED_TARGET libavcodec)
pkg_check_modules(AVFILTER REQUIRED IMPORTED_TARGET libavformat)
pkg_check_modules(AVDEVICE REQUIRED IMPORTED_TARGET libavdevice)
pkg_check_modules(AVUTIL REQUIRED IMPORTED_TARGET libavutil)
pkg_check_modules(SWRESAMPLE REQUIRED IMPORTED_TARGET libswresample)
pkg_check_modules(SWSCALE REQUIRED IMPORTED_TARGET libswscale)
add_library(FFMpeg INTERFACE IMPORTED GLOBAL)
target_include_directories(
FFmpeg INTERFACE
${AVCODEC_INCLUDE_DIRS}
${AVFILTER_INCLUDE_DIRS}
${AVDEVICE_INCLUDE_DIRS}
${AVUTIL_INCLUDE_DIRS}
${SWRESAMPLE_INCLUDE_DIRS}
${SWSCALE_INCLUDE_DIRS}
)
target_link_options(
FFmpeg INTERFACE
${AVCODEC_LDFLAGS}
${AVFILTER_LDFLAGS}
${AVDEVICE_LDFLAGS}
${AVUTIL_LDFLAGS}
${SWRESAMPLE_LDFLAGS}
${SWSCALE_LDFLAGS}
)
What have I done wrong/am not understanding?