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) { ...@@ -65,14 +65,28 @@ BUILTIN(InitEncodeContext) {
bitrate->ToUint32(&bitrate_int); bitrate->ToUint32(&bitrate_int);
framerate->ToUint32(&framerate_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 { 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()) { if (!enc->isReady()) {
// Fail to initialize LAIPIC_ENCODER::Encoder. // Then try to use libx264 to working with CPU
// Probaly cause of invalid arguments.
THROW_NEW_ERROR_RETURN_FAILURE(isolate, // Release old encoder
NewEvalError(MessageTemplate::kInvalidArgument)); 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; 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