I wrote a nodejs addon, compiled with node-gyp. It won't work on electron, but nodejs worked. The nodejs and electron node has the same version.
The addon do these things:
- Load ffmpeg static library and open a rtsp or local file.
- Convert the frame to rgba color to arraybuffer and call to electron's main process.
- The renderer process handle the data event and render the data to the canvas element.
In electron, the follow codes always return Protol not found
int status = avformat_open_input(&pFormatContext, url, NULL, NULL);
if (0 != status) {
av_log(NULL, AV_LOG_ERROR, "ffmpeg open error: %s\n", av_err2str(status));
return status;
}
The node-gyp configurations:
{
"targets": [{
"target_name": "ffmpeg",
"sources": ["src/ffmpeg/api/addon.c", "src/ffmpeg/api/ffmpeg.c"],
"include_dirs": [
"/home/my/ffmpeg_build/include"
],
"libraries": [
"-L$$PWD/../lib/ffmpeg-kylinux-aarch64",
"-lavformat",
"-lavcodec",
"-lavutil",
"-lswscale",
"-lswresample",
"-lx264",
"-lx265"
]
}]
}