Skip to content

Bug: Requesting hardware-accelerated video encoders crashes GitHub CI #117

@Vanilagy

Description

@Vanilagy

Describe the Bug

I noticed that querying the system for hardware-accelerated video encoder support crashes inside of GitHub Action's ubuntu-latest environment.

Here's the most minimal reproduction I was able to come up with:
https://github.com/Vanilagy/node-av-hardware-ci-crash

The relevant code is this:

import { AV_CODEC_ID_H264, HardwareContext } from 'node-av';

const hw = HardwareContext.auto();
const codec = hw.getEncoderCodec(AV_CODEC_ID_H264);

console.log(codec.name);

Which, before reaching the log statement, crashes with:

[CUDA @ 0x13f2c7c0] Cannot load libcuda.so.1
[CUDA @ 0x13f2c7c0] Could not dynamically load CUDA
implib-gen: libva-drm.so.2: failed to load library 'libva-drm.so.2' via dlopen: libva-drm.so.2: cannot open shared object file: No such file or directory
node: libva-drm.so.2.init.c:122: load_library: Assertion `0 && "Assertion in generated code"' failed.

I was able to circumvent this error in webcodecs-polyfill with this botched-together check:

const canUseHwAccel = () => {
	if (os.platform() !== 'linux') {
		return true; // Assume Windows/macOS work fine
	}

	// node-av downright crashes (with exit code 0, lol) if these aren't there, so we check ourselves
	const paths = [
		'/usr/lib/x86_64-linux-gnu/libva-drm.so.2',
		'/usr/lib/libva-drm.so.2',
		'/usr/lib/x86_64-linux-gnu/libcuda.so.1',
		'/usr/lib/libcuda.so.1',
	];
	return paths.some(p => fs.existsSync(p));
};

But, would be of course cool if it worked without having to do that.

To Reproduce

See above

Expected Behavior

If hardware encoders are not available, which I would assume for the default runner, then it should just not return a codec or return a software one.

Code Sample

See above

Relevant Log Output / Error Messages

See above

Node.js Version

v22

NodeAV Version

5.0.2

Operating System

Ubuntu 24.04

Installation Method

npm install

API Used

Low-Level API

Hardware Acceleration

Other

Additional Context

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions