vcpkg安装编译ffmpeg

有人总结了vcpkg的相关知识:博客
vcpkg发布在github上的链接
如果觉得浏览GitHub很慢(浏览,克隆都很慢),可以尝试:

  • 自己根据站长解析工具解析github对应链接的地址然后修改host文件,或许能稍微提速点
  • fork到自己仓库,然后在码云那边从github/gitlab导入,在码云那边浏览下载都挺快的
  • 自己科学上网吧,我发现我解析出来的域名IP地址都在新加坡的亚马逊数据中心那,估计也是被墙了,不然下载速度6Bytes/s啥意思。

在谷歌浏览器上,自己装个谷歌翻译扩展挺方便的,还有一个插件octotree, 可以在访问github时把仓库里的文件以文件目录呈现出来,不然平时进入某个目录后,都得点击上一级,看不到仓库的全貌,很不方便,通过文件目录可以随意跳转。

Vcpkg可帮助您在Windows,Linux和MacOS上管理C和C ++库。
具体的介绍还是看这位大哥的博客
反正就是很方便。或者看下GitHub的仓库,里面的docs讲得也很清楚。

进入powershell,到你克隆或普通下载的vcpkg目录下,执行:

PS> .\bootstrap-vcpkg.bat             // powershell下
Linux:~/$ ./bootstrap-vcpkg.sh        // Linux下

这样就可以编译源文件,然后生成一个vcpkg.exe.
在这里插入图片描述
Windows环境下,可以使用cmder命令行工具,和powershell一样也支持Linux下的shell命令(ls, tree, mkdir等),不过cmder比较美观一些,还有其它特点自行百度。

  • 这是一个git仓库,vcpkg.exe已经生成;
  • downloads是在安装第三方库中会下载的一些压缩包,源文件等,如果你提前把包下载号放进去,安装过程会比较快一些,主要是很多东西都在墙外,下载速度还有0.1Bytes/s的,自己科学上网吧。
  • 还有installed,这是你安装完第三方库并编译好的第三方库,都是些.h,.cpp之类的。

看下有没有ffmpeg:
在这里插入图片描述
在power shell的vcpkg目录下,直接安装:

.\vcpkg.exe install ffmpeg

安装过程:

PS F:\typora\FFmpeg\vcpkg-master\vcpkg-master> .\vcpkg.exe install ffmpeg                                                             The following packages will be built and installed:
    ffmpeg[avresample,core]:x86-windows
Starting package 1/1: ffmpeg:x86-windows
Building package ffmpeg[avresample,core]:x86-windows...
-- Using cached F:/typora/FFmpeg/vcpkg-master/vcpkg-master/downloads/ffmpeg-ffmpeg-n4.2.tar.gz
-- Using source at F:/typora/FFmpeg/vcpkg-master/vcpkg-master/buildtrees/ffmpeg/src/n4.2-b7812eeecc
-- Acquiring MSYS2...
-- Using cached F:/typora/FFmpeg/vcpkg-master/vcpkg-master/downloads/msys2-base-x86_64-20181211.tar.xz
gpg: /etc/pacman.d/gnupg/trustdb.gpg: trustdb created
gpg: no ultimately trusted keys found
gpg: starting migration from earlier GnuPG versions
gpg: porting secret keys from '/etc/pacman.d/gnupg/secring.gpg' to gpg-agent
gpg: migration succeeded
gpg: Generating pacman keyring master key...
gpg: key DCAA6702BFA902A2 marked as ultimately trusted
gpg: directory '/etc/pacman.d/gnupg/openpgp-revocs.d' created
gpg: revocation certificate stored as '/etc/pacman.d/gnupg/openpgp-revocs.d/CBA88710831C84C28C7A14F3DCAA6702BFA902A2.rev'
gpg: Done
==> Updating trust database...
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
==> Appending keys from msys2.gpg...
==> Locally signing trusted keys in keyring...
  -> Locally signing key D55E7A6D7CE9BA1587C0ACACF40D263ECA25678A...
  -> Locally signing key 123D4D51A1793859C2BE916BBBE514E53E0D0813...
  -> Locally signing key B91BCF3303284BF90CC043CA9F418C233E652008...
  -> Locally signing key 9DD0D4217D75A33B896159E6DA7EF2ABAEEA755C...
==> Importing owner trust values...
gpg: setting ownertrust to 4
gpg: setting ownertrust to 4
gpg: setting ownertrust to 4
gpg: inserting ownertrust of 4
==> Updating trust database...
gpg: marginals needed: 3  completes needed: 1  trust model: pgp
gpg: depth: 0  valid:   1  signed:   4  trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: depth: 1  valid:   4  signed:   3  trust: 0-, 0q, 0n, 4m, 0f, 0u
gpg: depth: 2  valid:   3  signed:   0  trust: 3-, 0q, 0n, 0m, 0f, 0u
:: Synchronizing package databases...
error: failed retrieving file 'mingw32.db' from repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
downloading mingw32.db...
error: failed retrieving file 'mingw32.db' from sourceforge.net : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
downloading mingw32.db...
downloading mingw32.db.sig...
downloading mingw64.db...
error: downloading mingw64.db...
downloading mingw64.db...
downloading mingw64.db.sig...
downloading msys.db...
downloading msys.db...
downloading msys.db...
downloading msys.db.sig...
:: Starting core system upgrade...
resolving dependencies...
looking for conflicting packages...

Packages (6) filesystem-2020.01-1  libzstd-1.4.4-2  mintty-1~3.1.0-1  msys2-runtime-3.0.7-6  pacman-5.2.1-6  zstd-1.4.4-2

Total Download Size:   14.60 MiB
Total Installed Size:  55.72 MiB
Net Upgrade Size:      -1.76 MiB

:: Proceed with installation? [Y/n]
:: Retrieving packages...
downloading filesystem-2020.01-1-x86_64.pkg.tar.xz...
downloading filesystem-2020.01-1-x86_64.pkg.tar.xz...

failed retrieving file 'mingw64.db' from repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'mingw64.db' from sourceforge.net : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'msys.db' from repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'msys.db' from sourceforge.net : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
warning: terminate other MSYS2 programs before proceeding
error: failed retrieving file 'filesystem-2020.01-1-x86_64.pkg.tar.xz' from repo.msys2.org : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'filesystem-2020.01-1-x86_64.pkg.tar.xz' from sourceforge.net : Operation too slow. Less than 1 bytes/sec transferred the last 10 seconds
error: failed retrieving file 'filesystem-2020.01-1-x86_64.pkg.tar.xz' from www2.futureware.at : expected download size exceeded

Interrupt signal received
-- Acquiring MSYS2... OK
-- Acquiring MSYS Packages...
-- Acquiring MSYS Packages... OK
-- Building Options: --enable-asm --enable-yasm --disable-doc --enable-debug --enable-runtime-cpudetect --disable-openssl --disable-ffmpeg --disable-ffplay --disable-ffprobe --disable-libvpx --disable-libx264 --disable-opencl --disable-lzma --disable-bzlib --enable-avresample  --disable-static --enable-shared --extra-cflags=-DHAVE_UNISTD_H=0
-- Building Release Options:  --extra-cflags=-MD --extra-cxxflags=-MD
-- Building ffmpeg for Release
-- Building Debug Options: --debug --extra-cflags=-MDd --extra-cxxflags=-MDd
-- Building ffmpeg for Debug
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\avcodec.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\avdevice.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\avfilter.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\avformat.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\avresample.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\avutil.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\swresample.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\debug\lib\swscale.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\avcodec.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\avdevice.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\avfilter.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\avformat.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\avresample.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\avutil.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\swresample.lib
-- Generating F:\typora\FFmpeg\vcpkg-master\vcpkg-master\packages\ffmpeg_x86-windows\lib\swscale.lib
-- Installing: F:/typora/FFmpeg/vcpkg-master/vcpkg-master/packages/ffmpeg_x86-windows/share/ffmpeg/copyright
-- Performing post-build validation
-- Performing post-build validation done
Building package ffmpeg[avresample,core]:x86-windows... done
Installing package ffmpeg[avresample,core]:x86-windows...
Installing package ffmpeg[avresample,core]:x86-windows... done
Elapsed time for package ffmpeg:x86-windows: 56.89 min

Total elapsed time: 56.89 min

可以看到,一共安装了56.89分钟,这还算是比较顺利的吧,每次缺什么东西,vcpkg会自己去对应的链接下载,然后就是各种网速太慢,服务器没有应答之类的,然后我在每次卡住的地方,复制一下链接,再科学上网(只在浏览器里有效,因为是插件嘛),直接把压缩包下载下来,然后放进downloads文件夹里,整个下载过程就是哪里卡住,我就去下载一下。
在把各种包,各种库下载完后,就开始编译ffmpeg源码了,它会编译发行版和DEBUG版的,然后就是等待,期间CPU利用率100%居高不下。

其实想想挺方便的,比起传统的安装第三方库,要自己解决依赖,自己编译啥的,这里就是一条龙服务啊,虽然由于网络原因,搞得我很难受,但是,编译啥的也挺快的,然后会自己把第三方库都管理起来。

以下是安装完包的样子:
在这里插入图片描述
在这里插入图片描述
都在installed文件夹里面。

接下来就把库继承到全局里面去:

.\vcpkg integrate install

集成成功了。

Applied user-wide integration for this vcpkg root.

然后我在VS2019里新建项目,直接包含头文件,看看有没有报错:
在这里插入图片描述
可以了,没有报错,敲得时候还有提示呢!
要是没有vcpkg,还得修改项目包含的库路径啥的,用了vcpkg就方便多了。
如果要继承到项目里去,得再查下资料了。我不管了。。。
还有要指定平台的,自己看官方的说明吧。
关键这跨平台也能用,就很方便了。

命令就几条

先编译vcpkg源码,生成.exe

PS> .\bootstrap-vcpkg.bat             // powershell下
Linux:~/$ ./bootstrap-vcpkg.sh        // Linux下

安装ffmpeg

.\vcpkg.exe install ffmpeg

3.集成到全局

.\vcpkg integrate install

4.VS2019新建项目验证下头文件能不能包含进来,不能的话,自己再找资料。

在这边发下编译完的带ffmpeg的vcpkg:

链接:https://pan.baidu.com/s/1vA_quO5ZuYcUXh6UtE63Tw
提取码:5cbq

发布了12 篇原创文章 · 获赞 0 · 访问量 289

猜你喜欢

转载自blog.csdn.net/ASCE_S/article/details/104142387