5

I'm trying to get hardware encoding working on ffmpeg.

I'm using Ubuntu 18.04 with its default kernel (4.15.0-50.54), ffmpeg package (3.4.6-0ubuntu0.18.04.1) and Nvidia drivers (390.116-0ubuntu0.18.04.1)

My hardware is a Lenovo Thinkpad P40 Yoga with a NVidia Quadro M500M (GM108GLM) which is supposed to have PureVideo HD 6 (VP6). I have not found a list of the codecs, pixel formats, bitrates, and resolutions supported by NVENC on this card, but it should be able to encode simple H264 videos at the very least. In fact, I have successfully used NVENC with OBS (Open Broadcaster Software) on the same computer in the past.

But ffmpeg gives the following messages:

[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

What can I do to fix it?

Here is the full output:

$ 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!
Tobia
  • 575
  • 2
  • 5
  • 15

1 Answers1

5

Unfortunately, the reason is that there is no NVENC capable device in your computer. As you can read on NVIDIA's Video Codec SDK documentation, GM108 is not supported (neither NVENC nor NVDEC).

danzel
  • 6,044
  • You're right, it does say that. But then how did I get hardware encoding working with OBS? I'm sure I did. Was it using Intel's chip? (I have a dual GPU, Intel and Nvidia) – Tobia May 27 '19 at 15:11
  • @Tobia was OBS using QuickSync? If so, then yes, it was on the Intel iGPU – You'reAGitForNotUsingGit May 27 '19 at 15:28
  • @Tobia your CPU is probably skylake (i7-6500U I guess?), which supports hardware accelerated encoding for some codecs via Intel Quick Sync (see here). There is an article about it in the Ffmpeg Wiki. – danzel May 27 '19 at 15:28
  • Thank you. Yes, Skylake i7-6600U. I was able to use the Intel hardware acceleration through VAAPI, using the examples on this page: https://trac.ffmpeg.org/wiki/Hardware/VAAPI It's 10x faster than the CPU encoder, the fans stay quiet and I can use the CPU to do other stuff in the meantime! – Tobia May 27 '19 at 15:37