准备
vcpkg安装ffmpeg
2、安装 ffmpeg
vcpkg install ffmpeg:x64-windows
vs中创建一个工程
使用
1、cmakelist.txt
cmake_minimum_required (VERSION 3.8)
include_directories("C:/Users/oceanstar/vcpkg/win/vcpkg/installed/x64-windows/include")
link_directories("C:/Users/oceanstar/vcpkg/win/vcpkg/installed/x64-windows/lib")
add_executable (cmake_test "cmake_test.cpp" "cmake_test.h")
target_link_libraries(
cmake_test
avfilter
avformat
avcodec
avutil
swresample
swscale)
代码
#include <stdio.h>
#include <Windows.h>
#define __STDC_CONSTANT_MACROS
#ifdef _WIN32
//Windows
extern "C"
{
#include "libavformat/avformat.h"
};
#else
//Linux...
#ifdef __cplusplus
extern "C"
{
#endif
#include <libavformat/avformat.h>
#ifdef __cplusplus
};
#endif
#endif
int main()
{
printf("%s\n", avcodec_configuration());
return 0;
}
效果:
参考: