导读 | ffmpeg 是音频处理方面非常强大非常有名的开源项目了,然而如 雷神 所说,“FFMPEG 难度比较大,却没有一个循序渐进,由简单到复杂的教程。现在网上的有关FFMPEG的教程多半难度比较大,不太适合刚接触 FFMPEG 的人学习;而且很多的例子程序编译通不过,极大地打消了学习的积极性”,对于平时只习惯在 Windows 下开发的开发的初学者来说,从零开始了解相关依赖,搭建起项目并调试 ffmpeg 并不是件容易的事,好在另一个非官方的 开源项目,提供了一整套 Windows 下,用 VS 来调试 ffmpeg 的解决方案——Shift Media Project。 本文使用最新版本的 ShiftMediaProject 的代码(20190607),展示在Windows10 下使用 VS2015 下载代码并成功编译的过程。在另一篇本文参考的 博文 中亦介绍了整个过程,不过由于是 20180307 写的,有些新的内容没有覆盖到,这里可当做是对其进行补充和拓展。同时也作为个人笔记分享出来,希望能帮助到更多刚好有需求的人。 |
目录 |
本文测试使用环境:
操作系统:Windows 10
编译使用开发环境:Visual Studio 2015
下载源代码工具:git 客户端
项目地址:https://github.com/ShiftMediaProject/FFmpeg
需要注意的是,克隆本地项目 至少需要有2层,因为项目的结构是这样子的:
- msvc (OutputDir) (该项目默认的 VS 编译输出的目录) - source (这个是需要的上一级目录,待会下载的依赖项目有很多,十几二十来个依赖项目都会下载到这里) - FFmpeg (这个是 clone 到本地的项目目录) - ..Any other libraries source code.. (其他的十几二十个依赖的项目)
准备好文件夹后,比如这里上面的 "source" 文件夹,在这个文件夹下,克隆代码下来
git clone https://github.com/ShiftMediaProject/FFmpeg.git
所有的 VS 项目相关的文件,都在 SMP 文件夹下,仔细查看该目录下的 readme 文件内容,按里面的说明进行。
This is a small list of steps in order to build FFmpeg into a msvc DLL and lib file. The projects contain Release and Debug builds for static lib files (Debug/Release) as well as dynamic shared dll files (DebugDLL/ReleaseDLL). Choose whichever project configuration meets your requirements. Note: FFmpeg requires C99 support in order to compile. Only Visual Studio 2013 or newer supports required C99 functionality and so any older version is not supported. Visual Studio 2013 or newer is required. If using an older unsupported version of Visual Studio the Intel compiler can be used to add in the required C99 capability. *** Using the Default Supplied Projects *** The supplied project files are created using default configuration options as used by the ShiftMediaProject. These projects use Visual Studio 2013/2015 and require certain additional dependencies to be built and available at compile time. Required project dependencies include: bzlib iconv zlib lzma libxml2 sdl2 libmp3lame libvorbis libspeex libopus libilbc libtheora libx264 libx265 libxvid libvpx libgme libmodplug libsoxr libfreetype fontconfig libfribidi libass gnutls libgcrypt libssh libcdio libcdio_paranoia libbluray opengl ffnvcodec libmfx Most of the above dependencies are supplied as part of the ShiftMediaProject repositories. These repositories can be manually downloaded or automatically cloned using the supplied project_get_dependencies.bat file. This file can also be used to check for and download any dependency updates at any point after the first clone of the library. Some of these dependency projects have additional requirements to those listed here. See the corresponding readme for each of the projects for further details. Many of the possible FFmpeg dependencies (and there dependencies) are available in the ShiftMediaProject repositories. However the following is a list of extra dependency options that require external downloads: 1) opengl (requires glext) a) Download glext.h and wglext.h from opengl.org. b) Save the header files into "OutputDir/include/gl/*". c) Download khrplatform.h from khronos.org d) Save the header file into "OutputDir/include/KHR/*". 2) ffnvcodec (requires nv-codec-headers) a) Download the nv-codec-headers repository from https://github.com/FFmpeg/nv-codec-headers b) Save the contents of the nv-codec-headers repositories "include" folder into "OutputDir/include/*". 3) AMF (requires Advanced Media Framework (AMF) SDK headers) a) Download the AMF repository from https://github.com/GPUOpen-LibrariesAndSDKs/AMF b) Save the contents of the AMF repositories "amf/public/include" into "OutputDir/include/AMF/*". *OutputDir is the "Output Directory" specified in the project properties. The default value of OutputDir is "..\..\msvc" relative to the FFmpeg source directory. An example of the expected directory structure is: - msvc (OutputDir) -> source - FFmpeg - ..Any other libraries source code.. Any dependencies supplied by ShiftMediaProject should be downloaded next to the FFmpeg folder as they will use the same OutputDir location. Projects to build each dependency can be found in the respective repository ./SMP directories or all together using the all inclusive ffmpeg_deps.sln. Only dependencies built from supplied ShiftMediaProject repositories are tested and supported. Using compiled dependencies from other sources may result in version mismatch or other issues. Although these external sources generally work fine any problems associated with them are not covered by ShiftMediaProject and so they should be used with discretion. *** Building with ASM *** In order to build FFmpeg using msvc you must first download and install NASM. NASM is required to compile all assembly files. 1) Visual Studio YASM integration can be downloaded from https://github.com/ShiftMediaProject/VSNASM/releases/latest 2) Once downloaded simply follow the install instructions included in the download.
Test
Test
项目地址:https://github.com/ShiftMediaProject/FFmpeg
Test
Test