吾有专门文章介绍如何在FFMPEG中使用NVIDIA硬件编解码。然后在Freeswitch中使用,并给别人提供了技术指导。
从某一时间开始,吾发现Freeswitch无法使用硬件编解码,编码无效,解码直接崩溃。吾后来使用ffmpeg测试:
ffplay -vcodec h264_cuvid sample_720p-2.h264
直接报错。
[quantum6@freeswitch freeswitch]$ ffplay -vcodec h264_cuvid sample_720p-2.h264
ffplay version 4.3.1 Copyright (c) 2003-2020 the FFmpeg developers
built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-44)
configuration: --extra-cflags='-I/usr/local/cuda/include -fPIC ' --extra-ldflags='-L/usr/local/cuda/lib64 -ldl ' --pkg-config-flags=--static --enable-shared --enable-static --enable-sdl --enable-gpl --enable-libx264 --enable-cuvid --enable-nvenc --enable-nonfree --nvcc='nvcc=/usr/local/cuda/bin/nvcc'
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, h264, from 'sample_720p-2.h264': 0KB sq= 0B f=0/0
Duration: N/A, bitrate: N/A
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720, 30 fps, 30 tbr, 1200k tbn, 60 tbc
[h264_cuvid @ 0x7f38c8028180] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps8) failed -> CUDA_ERROR_DEINITIALIZED: driver shutting down
[h264_cuvid @ 0x7f38c8028180] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps10) failed
[h264_cuvid @ 0x7f38c8028180] ctx->cvdl->cuvidGetDecoderCaps(&ctx->caps12) failed
Failed to open file 'sample_720p-2.h264' or configure filtergraph
nan : 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0
网上查了一下,以下方法测试无效:
./configure --enable-cuda --enable-nvenc --enable-cuvid --enable-libnpp --extra-cflags=-I --extra-ldflags=-L
吾反复安装系统,有十几次,都不成功。甚至有几次机器都开不了机。为什么开枪有问题?经过分析是显卡问题。于是吾就猜测,是显卡出问题,导致硬件编解码失败。