欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

基于visual studio 2017在Windows平台下编译FFmpeg

程序员文章站 2022-06-17 08:56:14
...

开始编译(前提是你前面已经配置好了编译环境)

编译ffmpeg,有两种方式,

微软官方Demo

可以按照微软官方的Demo教程来编译,先使用git下载,

git clone git://github.com/microsoft/FFmpegInterop.git
cd FFmpegInterop
git clone git://source.ffmpeg.org/ffmpeg.git

下载完成之后,目录结构如下:

FFmpegInterop\
    ffmpeg\              - ffmpeg source code from the latest release in git://github.com/FFmpeg/FFmpeg.git
    FFmpegInterop\       - FFmpegInterop WinRT component
    Samples\             - Sample Media Player applications in C++, C#, and JavaScript
    Tests\               - Unit tests for FFmpegInterop
    BuildFFmpeg.bat      - Helper script to build FFmpeg libraries as described in https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT
    FFmpegConfig.sh      - Internal script that contains FFmpeg configure options
    FFmpegWin8.1.sln     - Microsoft Visual Studio 2013 solution file for Windows 8.1 and Windows Phone 8.1 apps development
    FFmpegWin10.sln      - Microsoft Visual Studio 2015 solution file for Windows 10 apps development
    LICENSE
    README.md

直接在bash窗口中进入,执行执行编译相应版本的命令就行了

BuildFFmpeg.bat win10                     - Build for Windows 10 ARM, x64, and x86
BuildFFmpeg.bat phone8.1 ARM              - Build for Windows Phone 8.1 ARM only
BuildFFmpeg.bat win8.1 x86 x64            - Build for Windows 8.1 x86 and x64 only
BuildFFmpeg.bat phone8.1 win10 ARM        - Build for Windows 10 and Windows Phone 8.1 ARM only
BuildFFmpeg.bat win8.1 phone8.1 win10     - Build all architecture for all target platform

微软官方demo提供得是基于visual studio 2015的编译环境。如果你是visual studio 2017的话需要修改文件“BuildFFmpeg.bat”里面的路径。

下面示例是我修改的win10 x64

:Win10x64
if %BUILD.x64%==N goto Win10ARM
echo Building FFmpeg for Windows 10 apps x64...
echo:

setlocal
call "%VS150COMNTOOLS%..\..\VC\Auxiliary\Build\vcvarsall.bat" x64 store
set LIB=%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\lib\x64;%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64;%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x64;
set LIBPATH=%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\lib\x64;
set INCLUDE=%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\include;%VS150COMNTOOLS%..\..\VC\Tools\MSVC\%VCToolsVersion%\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTVersion%\ucrt;%UniversalCRTSdkDir%Include\%UCRTVersion%\um;%UniversalCRTSdkDir%Include\%UCRTVersion%\shared;%UniversalCRTSdkDir%Include\%UCRTVersion%\winrt;
::下面三行是原来的
::set LIB=%VSINSTALLDIR%VC\lib\store\amd64;%VSINSTALLDIR%VC\atlmfc\lib\amd64;%UniversalCRTSdkDir%lib\%UCRTVersion%\ucrt\x64;;%UniversalCRTSdkDir%lib\%UCRTVersion%\um\x64;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\lib\um\x64;;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Lib\um\x64
::set LIBPATH=%VSINSTALLDIR%VC\atlmfc\lib\amd64;%VSINSTALLDIR%VC\lib\amd64;
::set INCLUDE=%VSINSTALLDIR%VC\include;%VSINSTALLDIR%VC\atlmfc\include;%UniversalCRTSdkDir%Include\%UCRTVersion%\ucrt;%UniversalCRTSdkDir%Include\%UCRTVersion%\um;%UniversalCRTSdkDir%Include\%UCRTVersion%\shared;%UniversalCRTSdkDir%Include\%UCRTVersion%\winrt;C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\Include\um;

%MSYS2_BIN% --login -x %~dp0FFmpegConfig.sh Win10 x64
endlocal

忘了说了,记得现在环境变量里新建一个VS150COMNTOOLS,路径指向D:\Microsoft\Microsoft Visual Studio\2017\Enterprise\Common7\Tools,实际路径根据你安装的visual studio 2017的位置。

 

相关标签: ffmpeg