window编译ffmpeg支持NVIDIA GPU加速

编译

官方指导文档

根据官方文档一步一步操作,记录一下我遇到过的问题。

Unknown option “–disable-shared”.

LIEY@DESKTOP-85UH0NA MINGW64 /d/winshare/avproc/ffmpeg/ffmpeg-4.1.3
$ ./configure --enable-nonfree -–disable-shared --enable-cuda-sdk --enable-libnpp –-toolchain=msvc --extra-cflags=-I../nv_sdk --extra-ldflags=-libpath:../nv_sdk
Unknown option "-–disable-shared".
See ./configure --help for available options.

解决方案:
去除-–disable-shared参数

Unknown option “–-toolchain=msvc”

$ ./configure --enable-nonfree  --enable-cuda-sdk --enable-libnpp –-toolchain=msvc --extra-cflags=-I../nv_sdk --extra-ldflags=-libpath:../nv_sdk
Unknown option "–-toolchain=msvc".
See ./configure --help for available options.

解决方案:
先执行./configure --toolchain=msvc,在执行./configure --toolchain=msvc --enable-cuda-sdk --enable-nonfree --enable-libnpp --extra-cflags=-I../nv_sdk --extra-ldflags=-libpath:../nv_sdk

编译时报错

fftools/ffprobe.c(3088): error C2001: 常量中有换行符
fftools/ffprobe.c(3089): error C2146: 语法错误: 缺少“)(在标识符“writer_print_string”的前面)
fftools/ffprobe.c(3089): error C2198: “writer_print_string”: 用于调用的参数太少
fftools/ffprobe.c(3196): warning C4133: “=”: 从“int *”到“SectionID *”的类型不兼容
fftools/ffprobe.c(3486): warning C4133: “=”: 从“const int *”到“const SectionID *”的类型不兼容
...
...
fftools/cmdutils.c(1154): error C2065: “slib”: 未声明的标识符
fftools/cmdutils.c(1154): error C2296: “%”: 非法,左操作数包含“char [138]”类型
fftools/cmdutils.c(1154): error C2059: 语法错误:“数字上的错误后缀”
fftools/cmdutils.c(1154): error C2059: 语法错误:“%”
fftools/cmdutils.c(1154): error C2017: 非法的转义序列
fftools/cmdutils.c(1154): error C2015: 常量中的字符太多

解决方案:

ffprobe.c, cmdutils.c 之中使用了 CC_IDENT , 将相关代码行注释即可, 例如:

在这里插入图片描述

运行时出错

[h264_nvenc @ 000000125413BF80] Driver does not support the required nvenc API version. Required: 10.0 Found: 9.1
[h264_nvenc @ 000000125413BF80] The minimum required Nvidia driver for nvenc is 450.51 or newer

解决方案:

使用Geforce experence更新显卡驱动
在这里插入图片描述

编译examples时出错

“unistd.h”: No such file or directory

$ make examples
CC      doc/examples/filtering_audio.o
filtering_audio.c
doc/examples/filtering_audio.c(31): fatal error C1083: 无法打开包括文件: “unistd.h”: No such file or directory
make: *** [ffbuild/common.mak:67:doc/examples/filtering_audio.o] 错误 2

解决方案:

#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
#include <io.h>
#include <process.h>
#elif __unix__ // all unices not caught above
#include <unistd.h>
#endif

“usleep”未定义

$ make examples
CC      doc/examples/filtering_video.o
filtering_video.c
doc/examples/filtering_video.c(199): warning C4013: “usleep”未定义;假设外部返回 int
LD      doc/examples/filtering_video_g.exe
filtering_video.o : error LNK2019: 无法解析的外部符号 usleep,该符号在函数 display_frame 中被引用
doc/examples/filtering_video_g.exe : fatal error LNK1120: 1 个无法解析的外部命令
make: *** [Makefile:114:doc/examples/filtering_video_g.exe] 错误 96

解决方案:

使用Sleep替换usleep,注意Sleep参数的单位是毫秒

在这里插入图片描述

使用

nvidia显卡视频编解码能力

以上链接是官方对显卡视频编解码能力的介绍,对于编码大部分显卡都有并发路数限制。

编码:avcodec_find_encoder_by_name("h264_nvenc")

解码: avcodec_find_decoder_by_name("h264_cuvid")

需要注意的是,使用h264_cuvid解码出来的yuv格式是AV_PIX_FMT_NV12

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值