一 费了几天功夫, 一度怀疑实现不了, 结果发现非常简单, 安装msys64, 然后在msys64中安装ffmpeg, 然后就可以编译, 但运行也要在msys64环境下
二 下面的方法经测试可以用
一 下载ffmpeg
1.1
Releases · BtbN/FFmpeg-Builds · GitHub
1.2 解压到某一目录
二 修改cmakefiles.txt
cmake_minimum_required(VERSION 3.4.0)
project(video VERSION 0.1.0)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
cmake_policy(SET CMP0074 NEW)
#set(FFMPEG_ROOT "D:\\lib_for_vnc\\ffmpeg-4.4")
set(FFMPEG_ROOT "D:\\lib_for_vnc\\ffmpeg-n4.4.2-2-g7ffb7d4b04-win64-lgpl-shared-4.4")
#set(FFMPEG_ROOT "D:\\lib_for_vnc\\ffmpeg-n5.0-latest-win64-lgpl-shared-5.0")
find_package(FFMPEG COMPONENTS avcodec avutil avformat swscale)
include_directories(${FFMPEG_INCLUDE_DIRS})
message(STATUS ${FFMPEG_LIBRARIES})
include(CTest)
enable_testing()
add_executable(video main.cpp)
target_link_libraries(video ${FFMPEG_LIBRARIES} ${SDL2_LIBRARIES})
#target_link_libraries(hello ${jpeg_lib} ${GTK2_LIBRARIES})
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
#[==[
Provides the following variables:
* `FFMPEG_INCLUDE_DIRS`: Include directories necessary to use FFMPEG.
* `FFMPEG_LIBRARIES`: Libraries necessary to use FFMPEG. Note that this only
includes libraries for the components requested.
* `FFMPEG_VERSION`: The version of FFMPEG found.
The following components are supported:
* `avcodec`
* `avdevice`
* `avfilter`
* `avformat`
* `avresample`
* `avutil`
* `swresample`
* `swscale`
For each component, the following are provided:
* `FFMPEG_<component>_FOUND`: Libraries for the component.
* `FFMPEG_<component>_INCLUDE_DIRS`: Include directories for
the component.
* `FFMPEG_<component>_LIBRARIES`: Libraries for the component.
* `FFMPEG::<component>`: A target to use with `target_link_libraries`.
Note that only components requested with `COMPONENTS` or `OPTIONAL_COMPONENTS`
are guaranteed to set these variables or provide targets.
#]==]
function (_ffmpeg_find component headername)
find_path("FFMPEG_${component}_INCLUDE_DIR"
NAMES
"lib${component}/${headername}"
PATHS