ffmpeg h264_nvenc,“未找到支持 NVENC 的设备”

ffmpeg h264_nvenc,“未找到支持 NVENC 的设备”

我正在尝试让硬件编码在 ffmpeg 上运行。

我正在使用 Ubuntu 18.04 及其默认内核(4.15.0-50.54)、ffmpeg 包(3.4.6-0ubuntu0.18.04.1)和 Nvidia 驱动程序(390.116-0ubuntu0.18.04.1)

我的硬件是联想 Thinkpad P40 Yoga,配有 NVidia Quadro M500M (GM108GLM),据说配有 PureVideo HD 6 (VP6)。我找不到此卡上 NVENC 支持的编解码器、像素格式、比特率和分辨率的列表,但它至少应该能够编码简单的 H264 视频。事实上,我过去曾在同一台计算机上成功将 NVENC 与 OBS(开放广播软件)结合使用。

但是 ffmpeg 给出以下消息:

[h264_nvenc @ 0x562d21d512a0] Loaded Nvenc version 8.1
[h264_nvenc @ 0x562d21d512a0] Nvenc initialized successfully
[h264_nvenc @ 0x562d21d512a0] 1 CUDA capable devices found
[h264_nvenc @ 0x562d21d512a0] [ GPU #0 - < Quadro M500M > has Compute SM 5.0 ]
[h264_nvenc @ 0x562d21d512a0] OpenEncodeSessionEx failed: unsupported device (2)
[h264_nvenc @ 0x562d21d512a0] No NVENC capable devices found
[h264_nvenc @ 0x562d21d512a0] Nvenc unloaded

我该如何修复它?

以下是完整输出:

$ ffmpeg -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 -vcodec h264_nvenc test.mp4 -v 56
ffmpeg version 3.4.6-0ubuntu0.18.04.1 Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.3.0-16ubuntu3)
  configuration: --prefix=/usr --extra-version=0ubuntu0.18.04.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --enable-gpl --disable-stripping --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librubberband --enable-librsvg --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Splitting the commandline.
Reading option '-f' ... matched as option 'f' (force format) with argument 'lavfi'.
Reading option '-i' ... matched as input url with argument 'testsrc=duration=10:size=1280x720:rate=30'.
Reading option '-vcodec' ... matched as option 'vcodec' (force video codec ('copy' to copy stream)) with argument 'h264_nvenc'.
Reading option 'test.mp4' ... matched as output url.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '56'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 56.
Successfully parsed a group of options.
Parsing a group of options: input url testsrc=duration=10:size=1280x720:rate=30.
Applying option f (force format) with argument lavfi.
Successfully parsed a group of options.
Opening an input file: testsrc=duration=10:size=1280x720:rate=30.
detected 4 logical cores
[Parsed_testsrc_0 @ 0x562d21d4b660] Setting 'duration' to value '10'
[Parsed_testsrc_0 @ 0x562d21d4b660] Setting 'size' to value '1280x720'
[Parsed_testsrc_0 @ 0x562d21d4b660] Setting 'rate' to value '30'
[Parsed_testsrc_0 @ 0x562d21d4b660] size:1280x720 rate:30/1 duration:10.000000 sar:1/1
[AVFilterGraph @ 0x562d21d4a840] query_formats: 2 queried, 1 merged, 0 already done, 0 delayed
[lavfi @ 0x562d21d498c0] All info found
[lavfi @ 0x562d21d498c0] stream 0: start_time: 0.000 duration: -307445734561825856.000
[lavfi @ 0x562d21d498c0] format: start_time: 0.000 duration: -9223372036854.775 bitrate=0 kb/s
Input #0, lavfi, from 'testsrc=duration=10:size=1280x720:rate=30':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #0:0, 1, 1/30: Video: rawvideo, 1 reference frame (RGB[24] / 0x18424752), rgb24, 1280x720 [SAR 1:1 DAR 16:9], 0/1, 30 tbr, 30 tbn, 30 tbc
Successfully opened the file.
Parsing a group of options: output url test.mp4.
Applying option vcodec (force video codec ('copy' to copy stream)) with argument h264_nvenc.
Successfully parsed a group of options.
Opening an output file: test.mp4.
[file @ 0x562d21d6d720] Setting default whitelist 'file,crypto'
Successfully opened the file.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (h264_nvenc))
Press [q] to stop, [?] for help
cur_dts is invalid (this is harmless if it occurs once at the start per stream)
[rawvideo @ 0x562d21d4f740] PACKET SIZE: 2764800, STRIDE: 3840
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] Setting 'video_size' to value '1280x720'
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] Setting 'pix_fmt' to value '2'
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] Setting 'time_base' to value '1/30'
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] Setting 'pixel_aspect' to value '1/1'
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] Setting 'sws_param' to value 'flags=2'
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] Setting 'frame_rate' to value '30/1'
[graph 0 input from stream 0:0 @ 0x562d21d6f9e0] w:1280 h:720 pixfmt:rgb24 tb:1/30 fr:30/1 sar:1/1 sws_param:flags=2
[format @ 0x562d21d6e520] compat: called with args=[yuv420p|nv12|p010le|yuv444p|yuv444p16le|bgr0|rgb0|cuda]
[format @ 0x562d21d6e520] Setting 'pix_fmts' to value 'yuv420p|nv12|p010le|yuv444p|yuv444p16le|bgr0|rgb0|cuda'
[auto_scaler_0 @ 0x562d21d72da0] Setting 'flags' to value 'bicubic'
[auto_scaler_0 @ 0x562d21d72da0] w:iw h:ih flags:'bicubic' interl:0
[format @ 0x562d21d6e520] auto-inserting filter 'auto_scaler_0' between the filter 'Parsed_null_0' and the filter 'format'
[AVFilterGraph @ 0x562d21d6e7e0] query_formats: 4 queried, 2 merged, 1 already done, 0 delayed
[auto_scaler_0 @ 0x562d21d72da0] picking rgb0 out of 7 ref:rgb24 alpha:0
[swscaler @ 0x562d21d73b40] Forcing full internal H chroma due to input having non subsampled chroma
[auto_scaler_0 @ 0x562d21d72da0] w:1280 h:720 fmt:rgb24 sar:1/1 -> w:1280 h:720 fmt:rgb0 sar:1/1 flags:0x4
Loaded lib: libcuda.so.1
Loaded sym: cuInit
Loaded sym: cuDeviceGetCount
Loaded sym: cuDeviceGet
Loaded sym: cuDeviceGetName
Loaded sym: cuDeviceComputeCapability
Loaded sym: cuCtxCreate_v2
Loaded sym: cuCtxPushCurrent_v2
Loaded sym: cuCtxPopCurrent_v2
Loaded sym: cuCtxDestroy_v2
Loaded sym: cuMemAlloc_v2
Loaded sym: cuMemFree_v2
Loaded sym: cuMemcpy2D_v2
Loaded sym: cuGetErrorName
Loaded sym: cuGetErrorString
Loaded lib: libnvidia-encode.so.1
Loaded sym: NvEncodeAPICreateInstance
Loaded sym: NvEncodeAPIGetMaxSupportedVersion
[h264_nvenc @ 0x562d21d512a0] Loaded Nvenc version 8.1
[h264_nvenc @ 0x562d21d512a0] Nvenc initialized successfully
[h264_nvenc @ 0x562d21d512a0] 1 CUDA capable devices found
[h264_nvenc @ 0x562d21d512a0] [ GPU #0 - < Quadro M500M > has Compute SM 5.0 ]
[h264_nvenc @ 0x562d21d512a0] OpenEncodeSessionEx failed: unsupported device (2)
[h264_nvenc @ 0x562d21d512a0] No NVENC capable devices found
[h264_nvenc @ 0x562d21d512a0] Nvenc unloaded
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[AVIOContext @ 0x562d21d6d7a0] Statistics: 0 seeks, 0 writeouts
Conversion failed!

答案1

不幸的是,原因是您的计算机中没有支持 NVENC 的设备。正如您在 NVIDIA 的视频编解码器 SDK 文档,不支持GM108(神经网络也不直流电压调节器)。

相关内容