VS2015编译FFMpeg3.2.4
工作需求又不熟悉Linux编译环境,mingw感觉也用不太来,所以折腾直接采用vs2015直接编译FFMpeg,在此感谢ShiftMediaProject大神提供了vs2015的工程,感谢《使用vs2013或vs2015 编译ffmpeg》http://www.jianshu.com/p/e72e6dce7f23提供了问题解决思路:
以下是我采用VS2015编译FFMpeg的全过程:
1、从这里完整下载所有源代码
https://github.com/ShiftMediaProject
完整链接(可以直接迅雷下载):
https://codeload.github.com/ShiftMediaProject/FFmpeg/zip/master
2、然后解压到如E:\ffmpeg\ffmpeg-vs2015\FFmpeg
3、进入E:\FFMpeg\FFmpeg-VS2015\FFmpeg\SMP,执行SMP下的project_get_dependencies.bat,下载时间有点久,耐心等待一会。
4、下载vsyasm-1.3.0-win32,地址
https://github.com/ShiftMediaProject/VSYASM/releases/download/0.2/VSYASM.zip
(试过其他版本,多少有点问题,最后用这个地址的解决了)
5、解压到
C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations
并将yasm-32.exe改名为yasm.exe
(因为部分项目的project工程文件写了yasm.target的路径,如libavcodec)
网上的 http://www.jianshu.com/p/e72e6dce7f23 这篇文章应该是有点问题的,没有和原作者确认,但是采用他的方式编译失败
8、拷贝yasm.exe, yasm.props、yasm.targets、yasm.xml 这4个文件到
C:\Program Files\Microsoft Visual Studio 14.0\VC
7、下载nvidia_video_sdk_6.0.1.zip,地址如下,并解压到E:\FFMpeg\FFmpeg-VS2015
8、打开工程ffmpeg_deps.sln,此时应该可以看到所有工程都导入成功了
9、设置libavdevice工程属性,设置附加包含目录和lib库
$(SolutionDir)..\..\nvidia_video_sdk_6.0.1\Samples\common\inc
Lib库(需要逐一配置)
$(SolutionDir)..\..\nvidia_video_sdk_6.0.1\Samples\common\libWin32
10、libavcodec项目右键 -Properties - VC++ Directories,同上添加上述的inc和lib。
11、设置为X86方式编译最后有4个失败,
5> opengl_enc.c
5>..\libavdevice\opengl_enc.c(43):fatal error C1083: Cannot open include file: 'GL/glext.h': No such file ordirectory
6>------已启动生成: 项目: ffmpeg, 配置:Debug Win32 ------
7>------已启动生成: 项目: ffplay, 配置:Debug Win32 ------
8>------已启动生成: 项目: ffprobe, 配置:Debug Win32 ------
6>C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1189,5):warning MSB8012:TargetPath(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffmpeg.exe)does not match the Linker's OutputFile property value(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\msvc\bin\x86\ffmpeg.exe). This maycause your project to build incorrectly. To correct this, please make sure that$(OutDir), $(TargetName) and $(TargetExt) property values match the valuespecified in %(Link.OutputFile).
7>C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1189,5):warning MSB8012:TargetPath(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffplay.exe)does not match the Linker's OutputFile property value(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\msvc\bin\x86\ffplay.exe). This maycause your project to build incorrectly. To correct this, please make sure that$(OutDir), $(TargetName) and $(TargetExt) property values match the valuespecified in %(Link.OutputFile).
8>C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1189,5):warning MSB8012:TargetPath(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffprobe.exe)does not match the Linker's OutputFile property value(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\msvc\bin\x86\ffprobe.exe). Thismay cause your project to build incorrectly. To correct this, please make surethat $(OutDir), $(TargetName) and $(TargetExt) property values match the valuespecified in %(Link.OutputFile).
6>LINK: fatal error LNK1181: cannot open input file 'libavdeviced.lib'
8>LINK: fatal error LNK1181: cannot open input file 'libavdeviced.lib'
7>LINK : fatal errorLNK1181: cannot open input file 'libavdeviced.lib'
12.从Mingw\include\GL\glext.h拷贝glext.h到C:\Program Files\WindowsKits\8.1\Include\um\gl下重新编译libavdevice通过
13.编译ffplay失败,错误信息为
1>------已启动生成: 项目: ffmpeg, 配置:Debug Win32 ------
1>C:\ProgramFiles\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(1189,5):warning MSB8012: TargetPath(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffmpeg.exe)does not match the Linker's OutputFile property value(E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\msvc\bin\x86\ffmpeg.exe). This maycause your project to build incorrectly. To correct this, please make sure that$(OutDir), $(TargetName) and $(TargetExt) property values match the valuespecified in %(Link.OutputFile).
1>libavdeviced.lib(SDL_dynapi.obj): warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:LBR' specification
1> Creating libraryE:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffmpeg.liband objectE:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffmpeg.exp
1>libavcodecd.lib(xvid.obj): error LNK2019: unresolved external symbol _bgr_to_yv12_mmx referenced infunction _xvid_gbl_init
1>libavcodecd.lib(xvid.obj): error LNK2019: unresolved external symbol _rgb_to_yv12_mmx referenced infunction _xvid_gbl_init
1>libavcodecd.lib(xvid.obj): error LNK2019: unresolved external symbol _bgra_to_yv12_mmx referenced infunction _xvid_gbl_init
1>libavcodecd.lib(xvid.obj): error LNK2019: unresolved external symbol _rgba_to_yv12_mmx referenced infunction _xvid_gbl_init
1> libavcodecd.lib(xvid.obj): error LNK2019: unresolved external symbol _yuyv_to_yv12_mmx referenced infunction _xvid_gbl_init
14重新编译下libxvidcore、libavcodec,然后再重新编译FFMpeg就可以了
1> ffplay.vcxproj ->E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffplay.exe
2> ffprobe.vcxproj ->E:\Work\SourceCode\FFMpeg\FFMpeg-Vs2015-SMP\FFmpeg\FFMpeg\SMP\..\..\..\msvc\ffprobe.exe