Commit 4e041468 authored by Linshizhi's avatar Linshizhi

Change to libx264 with CPU once h264_nvenc fail to init.

parent 4d3dda41
......@@ -65,14 +65,28 @@ BUILTIN(InitEncodeContext) {
bitrate->ToUint32(&bitrate_int);
framerate->ToUint32(&framerate_int);
// First try to use h264_nvenc which may failed due
// to host has no GPU.
enc = new LAIPIC_ENCODER::Encoder {
libpath_cppstr, outpath, width_int, height_int, bitrate_int, AV_PIX_FMT_YUV420P, 30, "h264_nvenc" };
libpath_cppstr, outpath, width_int, height_int, bitrate_int,
AV_PIX_FMT_YUV420P, 30, "h264_nvenc" };
if (!enc->isReady()) {
// Fail to initialize LAIPIC_ENCODER::Encoder.
// Probaly cause of invalid arguments.
THROW_NEW_ERROR_RETURN_FAILURE(isolate,
NewEvalError(MessageTemplate::kInvalidArgument));
// Then try to use libx264 to working with CPU
// Release old encoder
enc->close();
enc = new LAIPIC_ENCODER::Encoder {
libpath_cppstr, outpath, width_int, height_int, bitrate_int,
AV_PIX_FMT_YUV420P, 30, "libx264"};
if (!enc->isReady()) {
// Fail to initialize LAIPIC_ENCODER::Encoder.
// Probaly cause of invalid arguments.
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewEvalError(MessageTemplate::kInvalidArgument));
}
}
inited = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment