There was a note about linux testing so I wanted to post some limited results.
Wanted to try and figure out what nvidia options were avail on a machine to get it working I did:
var ret = LibNvEnc.TryInitialize(out var err);
if (ret != LibNcEncInitializeStatus.Success)
throw new Exception($"Unable to initialize nvidia {ret} {err}");
LibCuda.Initialize();
var descriptions = CuDevice.GetDescriptions().ToArray();
if (descriptions.Length == 0)
throw new Exception("Cannot find any nvidia cuda devices");
var first = descriptions.First();
var dev = CuDevice.GetDevice(first.Device.Handle);
using var context = dev.CreateContext();
var ps = new NvEncOpenEncodeSessionExParams {
Version = LibNvEnc.NV_ENC_OPEN_ENCODE_SESSION_EX_PARAMS_VER,
ApiVersion = LibNvEnc.NVENCAPI_VERSION,
Device = context.Handle,
DeviceType = NvEncDeviceType.Cuda
};
using var encoder = LibNvEnc.OpenEncoder(ref ps);
var cap = new NvEncCapsParam { CapsToQuery = NvEncCaps.SupportMultipleRefFrames };
var ret = 0;
encoder.GetEncodeCaps(NvEncCodecGuids.Hevc, ref cap, ref ret);
finally after running dotnet build I needed to link in the system libraries to match the names .net looked for:
I am not sure if there is value in switching NvEncoder to be a class without a parameterless constructor to make it a bit more obvious you can't just init it that way.
There was a note about linux testing so I wanted to post some limited results. Wanted to try and figure out what nvidia options were avail on a machine to get it working I did:
Then for an app
finally after running dotnet build I needed to link in the system libraries to match the names .net looked for:
I am not sure if there is value in switching NvEncoder to be a class without a parameterless constructor to make it a bit more obvious you can't just init it that way.