FFmpeg is compiled in VS2017

Today, stumbled in gayhub a fast hardware engineering, the whole project VS compile FFMPEG library, including all dependent libraries VS generated without Mingw such as Linux environment.

The recording process is simple, to avoid future reloaded system, notes.

https://github.com/ShiftMediaProject/FFmpeg

git clone this project, run SMP \ project_get_dependencies.bat download.

But I did not know before this automatic downloading dependencies, I direct clone all the items of this man ......

View SMP \ readme.txt, found that in addition to the associated libraries, but also requires a separate download something he had no band.

You need to build a directory that contains these separate header file.

Such as call __FFMPEG_Need, include the establishment of a directory, then create four directories under

AMF

ffnvcodec

gl

KHR

And put these two files in the directory gl

https://www.khronos.org/registry/OpenGL/api/GL/glext.h

https://www.khronos.org/registry/OpenGL/api/GL/wglext.h

KHR into

https://www.khronos.org/registry/EGL/api/KHR/khrplatform.h

Then clone this project

https://github.com/FFmpeg/nv-codec-headers

The contents of this project include, directly into our current directory to include, that is, copy the directory ffnvcodec

Finally clone AMF

https://github.com/GPUOpen-LibrariesAndSDKs/AMF

The

amf/public/include

AMF content into your directory, that is, the

components

core

Copied to the AMF directory

So far, include catalog ready, and so will compile the project, add this directory to all projects include path, you can choose to join the global VS include directory.

========================================

接下来下载YASM和NASM

http://yasm.tortall.net/Download.html

 YASM只需下载exe即可,32还是64位随意,我只需要32位,

http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win32.exe

下好后改名yasm.exe

建个目录,比如

E:\Yasm

把yasm.exe放入

新建环境变量YASMPATH,写入路径地址

注意路径最后要有反斜杠\结尾

然后下载NASM

https://www.nasm.us/pub/nasm/releasebuilds/2.14/

要下载安装器,不知道为什么,我下载zip好像失败了,所以只能用exe安装版本。

https://www.nasm.us/pub/nasm/releasebuilds/2.14/win32/nasm-2.14-installer-x86.exe

把nasm安装一下,比如

E:\nasm-2.14

之后同上,新建环境变量NASMPATH,加入路径

 

因为我是单独clone的所有工程,所以

https://github.com/ShiftMediaProject/VSYASM

https://github.com/ShiftMediaProject/VSNASM

在这2个工程里,把每个工程的

.props
.targets
.xml

类型配置文件,1个工程有3个文件,总共6个文件,复制到类似下面的目录中,也就是你VS2017的配置目录,VS默认只有masm的配置

D:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\VC\VCTargets\BuildCustomizations

然后打开SMP\ffmpeg_deps.sln工程,如果提示更新一些VS组件就都选是更新。

如果工程全都可以打开,不缺少工程的话,那么配置就OK了。如果有加载不了的项目,分2种情况

1.如果是少工程就补全工程。

其他工程都与ffmpeg同级。

ffmpeg

libass

这样同级目录

2.如果工程文件目录都正常存在,但是还是加载不了,可能就是YASM和NASM配置有问题,但是现在应该都配置好了,我是先有问题,才后装的NASM。

最后,你应该得到一个可以打开

FFmpeg\SMP\ffmpeg_deps.sln

之后,所有工程都可以加载上的,没有Load Fail的Solution

 

试着编译,如果显示Windows SDK不正常,修改一下所有工程使用的SDK即可,默认似乎是Win8 SDK,我重装VS2017似乎只有Win10 SDK,没有Win8,所以改成Win10 SDK才能编译。

继续,如果编译libav之类的库,一定会提示缺少头文件,因为最开始单独下载的那些include头文件没有放进VS全局目录,加入即可。

比如

E:\PProjects\GitDownloads\__FFMPEG_Need\include

然后再次编译,直接编译debug即可,因为主要是学习原理,而非测试运行效率。

如果全都编译通过没有错误,就可以再打开

FFmpeg\SMP\ffmpeg.sln

把ffplay之类的也编译了,对我来说ffplay才是重点,因为这是播放器应用实例,我个人能在网上找到播放视频最实用的例子了。

展开ffplay工程,ffplay.c文件,如果直接编译这个ffplay,生成的ffplay.exe播放视频会提示音频初始化失败而播放不出声音,似乎是因为dsound初始化失败了。

根据之前2次编译ffplay的经验,在文件头加入window头

#include <Windows.h>

搜索SDL_OpenAudioDevice

在这行前加入

CoInitialize(NULL);

再编译即可修复音频问题。

我的FFMPEG工程目录在

E:\PProjects\GitDownloads\FFmpeg

那么生成的文件在

E:\PProjects\msvc\bin\x86\ffplay.exe

这个msvc目录似乎是自动生成的

 

还不算完,现在要测试一个带字幕的视频文件,并且用ffplay播放字幕。

一般的命令,比如ffplay mv.mkv是不会播放视频的字幕的。

想播放字幕,正确的用法是

ffplay -vf subtitles=mv.mkv mv.mkv

外挂字幕同理

ffplay -vf subtitles=mv.ass mv.mkv

这样才行

 

至此结束,可以开始断点跟踪代码走向了,最叼的是全VS工程,完全可控的代码,让你有心情查看每一个库的实现,而不是像屎一样的那种一堆源码,自动编译完就能用的那种垃圾。

Guess you like

Origin www.cnblogs.com/cfas/p/11974426.html