windows 10 vscode cmake ffmpeg 编程环境搭建(修改)

一 费了几天功夫, 一度怀疑实现不了, 结果发现非常简单, 安装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
   
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值