使用带有 ffmpeg 的 h264_cuvid 解码器时出错
Error while using h264_cuvid decoder with ffmpeg
我正在尝试使用 NVIDIA cuvid 硬件加速和 ffmpeg.
解码视频
我使用的是 NVIDIA GeForce GT 745M 显卡(GPU:GK107),它与 NVIDIA here
指定的 cuvid 兼容
我用以下标志编译了 ffmpeg:
./configure --enable-cuda --enable-nvenc --enable-cuvid
然后,我使用 ffmpeg 和以下命令行:
ffmpeg.exe -hwaccel cuvid -c:v h264_cuvid -i video.mkv video.mkv
ffmpeg 完成,似乎无法打开 cuvid 功能:
Cannot load cuvidGetDecoderCaps
[h264_cuvid @ 07047b80] Failed loading nvcuvid.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (libx264))
Stream #0:1 -> #0:1 (ac3 (native) -> vorbis (libvorbis))
Stream #0:3 -> #0:2 (subrip (srt) -> ass (ssa))
Error while opening decoder for input stream #0:0 : Unknown error occurred
在ffmpeg源代码中,我可以发现这个错误信息是由下面的宏打印出来的:
#define LOAD_SYMBOL(fun, tp, symbol) \
do { \
if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) { \
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
ret = AVERROR_UNKNOWN; \
goto error; \
} \
av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
} while (0)
调用者:
static inline int cuvid_load_functions(CuvidFunctions **functions)
{
GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
LOAD_SYMBOL(cuvidGetDecoderCaps, tcuvidGetDecoderCaps, "cuvidGetDecoderCaps");
LOAD_SYMBOL(cuvidCreateDecoder, tcuvidCreateDecoder, "cuvidCreateDecoder");
LOAD_SYMBOL(cuvidDestroyDecoder, tcuvidDestroyDecoder, "cuvidDestroyDecoder");
LOAD_SYMBOL(cuvidDecodePicture, tcuvidDecodePicture, "cuvidDecodePicture");
#ifdef __CUVID_DEVPTR64
LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame64");
LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64");
#else
LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame");
LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame");
#endif
LOAD_SYMBOL(cuvidCtxLockCreate, tcuvidCtxLockCreate, "cuvidCtxLockCreate");
LOAD_SYMBOL(cuvidCtxLockDestroy, tcuvidCtxLockDestroy, "cuvidCtxLockDestroy");
LOAD_SYMBOL(cuvidCtxLock, tcuvidCtxLock, "cuvidCtxLock");
LOAD_SYMBOL(cuvidCtxUnlock, tcuvidCtxUnlock, "cuvidCtxUnlock");
LOAD_SYMBOL(cuvidCreateVideoSource, tcuvidCreateVideoSource, "cuvidCreateVideoSource");
LOAD_SYMBOL(cuvidCreateVideoSourceW, tcuvidCreateVideoSourceW, "cuvidCreateVideoSourceW");
LOAD_SYMBOL(cuvidDestroyVideoSource, tcuvidDestroyVideoSource, "cuvidDestroyVideoSource");
LOAD_SYMBOL(cuvidSetVideoSourceState, tcuvidSetVideoSourceState, "cuvidSetVideoSourceState");
LOAD_SYMBOL(cuvidGetVideoSourceState, tcuvidGetVideoSourceState, "cuvidGetVideoSourceState");
LOAD_SYMBOL(cuvidGetSourceVideoFormat, tcuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat");
LOAD_SYMBOL(cuvidGetSourceAudioFormat, tcuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat");
LOAD_SYMBOL(cuvidCreateVideoParser, tcuvidCreateVideoParser, "cuvidCreateVideoParser");
LOAD_SYMBOL(cuvidParseVideoData, tcuvidParseVideoData, "cuvidParseVideoData");
LOAD_SYMBOL(cuvidDestroyVideoParser, tcuvidDestroyVideoParser, "cuvidDestroyVideoParser");
GENERIC_LOAD_FUNC_FINALE(cuvid);
}
有人知道 cuvid 是否需要特定文件来加载其功能吗?
有什么问题的线索吗?
我没有问题了。
我在 ffmpeg 编译期间忘记使用 libnpp。
我当前的配置是:
./configure --enable-cuda --enable-nvenc --enable-cuvid --enable-libnpp --extra-cflags=-I<path_to_libnpp_headers> --extra-ldflags=-L<path_to_libnpp_libraries>
我正在尝试使用 NVIDIA cuvid 硬件加速和 ffmpeg.
解码视频我使用的是 NVIDIA GeForce GT 745M 显卡(GPU:GK107),它与 NVIDIA here
指定的 cuvid 兼容我用以下标志编译了 ffmpeg:
./configure --enable-cuda --enable-nvenc --enable-cuvid
然后,我使用 ffmpeg 和以下命令行:
ffmpeg.exe -hwaccel cuvid -c:v h264_cuvid -i video.mkv video.mkv
ffmpeg 完成,似乎无法打开 cuvid 功能:
Cannot load cuvidGetDecoderCaps
[h264_cuvid @ 07047b80] Failed loading nvcuvid.
Stream mapping:
Stream #0:0 -> #0:0 (h264 (h264_cuvid) -> h264 (libx264))
Stream #0:1 -> #0:1 (ac3 (native) -> vorbis (libvorbis))
Stream #0:3 -> #0:2 (subrip (srt) -> ass (ssa))
Error while opening decoder for input stream #0:0 : Unknown error occurred
在ffmpeg源代码中,我可以发现这个错误信息是由下面的宏打印出来的:
#define LOAD_SYMBOL(fun, tp, symbol) \
do { \
if (!((f->fun) = (tp*)dlsym(f->lib, symbol))) { \
av_log(NULL, AV_LOG_ERROR, "Cannot load %s\n", symbol); \
ret = AVERROR_UNKNOWN; \
goto error; \
} \
av_log(NULL, AV_LOG_TRACE, "Loaded sym: %s\n", symbol); \
} while (0)
调用者:
static inline int cuvid_load_functions(CuvidFunctions **functions)
{
GENERIC_LOAD_FUNC_PREAMBLE(CuvidFunctions, cuvid, NVCUVID_LIBNAME);
LOAD_SYMBOL(cuvidGetDecoderCaps, tcuvidGetDecoderCaps, "cuvidGetDecoderCaps");
LOAD_SYMBOL(cuvidCreateDecoder, tcuvidCreateDecoder, "cuvidCreateDecoder");
LOAD_SYMBOL(cuvidDestroyDecoder, tcuvidDestroyDecoder, "cuvidDestroyDecoder");
LOAD_SYMBOL(cuvidDecodePicture, tcuvidDecodePicture, "cuvidDecodePicture");
#ifdef __CUVID_DEVPTR64
LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame64");
LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame64");
#else
LOAD_SYMBOL(cuvidMapVideoFrame, tcuvidMapVideoFrame, "cuvidMapVideoFrame");
LOAD_SYMBOL(cuvidUnmapVideoFrame, tcuvidUnmapVideoFrame, "cuvidUnmapVideoFrame");
#endif
LOAD_SYMBOL(cuvidCtxLockCreate, tcuvidCtxLockCreate, "cuvidCtxLockCreate");
LOAD_SYMBOL(cuvidCtxLockDestroy, tcuvidCtxLockDestroy, "cuvidCtxLockDestroy");
LOAD_SYMBOL(cuvidCtxLock, tcuvidCtxLock, "cuvidCtxLock");
LOAD_SYMBOL(cuvidCtxUnlock, tcuvidCtxUnlock, "cuvidCtxUnlock");
LOAD_SYMBOL(cuvidCreateVideoSource, tcuvidCreateVideoSource, "cuvidCreateVideoSource");
LOAD_SYMBOL(cuvidCreateVideoSourceW, tcuvidCreateVideoSourceW, "cuvidCreateVideoSourceW");
LOAD_SYMBOL(cuvidDestroyVideoSource, tcuvidDestroyVideoSource, "cuvidDestroyVideoSource");
LOAD_SYMBOL(cuvidSetVideoSourceState, tcuvidSetVideoSourceState, "cuvidSetVideoSourceState");
LOAD_SYMBOL(cuvidGetVideoSourceState, tcuvidGetVideoSourceState, "cuvidGetVideoSourceState");
LOAD_SYMBOL(cuvidGetSourceVideoFormat, tcuvidGetSourceVideoFormat, "cuvidGetSourceVideoFormat");
LOAD_SYMBOL(cuvidGetSourceAudioFormat, tcuvidGetSourceAudioFormat, "cuvidGetSourceAudioFormat");
LOAD_SYMBOL(cuvidCreateVideoParser, tcuvidCreateVideoParser, "cuvidCreateVideoParser");
LOAD_SYMBOL(cuvidParseVideoData, tcuvidParseVideoData, "cuvidParseVideoData");
LOAD_SYMBOL(cuvidDestroyVideoParser, tcuvidDestroyVideoParser, "cuvidDestroyVideoParser");
GENERIC_LOAD_FUNC_FINALE(cuvid);
}
有人知道 cuvid 是否需要特定文件来加载其功能吗? 有什么问题的线索吗?
我没有问题了。
我在 ffmpeg 编译期间忘记使用 libnpp。
我当前的配置是:
./configure --enable-cuda --enable-nvenc --enable-cuvid --enable-libnpp --extra-cflags=-I<path_to_libnpp_headers> --extra-ldflags=-L<path_to_libnpp_libraries>