cool man
14th July 2020, 12:36
I am using libx264 compiled from source. It was configured to get both libx264.dll and libx264.lib by this command
./configure --disable-cli --enable-shared --extra-ldflags=-Wl,--output-def=libx264.def
I am using the libx264 API in my screen-sharing program with the preset - "veryfast", tune - "zerolatency", profile - "high" and also the following settings.
param.i_csp = X264_CSP_BGRA;
param.i_threads = 1;
param.i_width = width;
param.i_height = height;
param.i_fps_num = fps;
param.i_fps_den = 1;
param.rc.i_bitrate = bitrate;
param.rc.i_rc_method = X264_RC_ABR;
param.rc.b_filler = true;
param.rc.f_rf_constant = (float)0;
param.rc.i_vbv_max_bitrate = param.rc.i_bitrate;
param.rc.i_vbv_buffer_size = param.rc.i_bitrate;
param.b_repeat_headers = 0;
param.b_annexb = 1;
For these settings the program works fine. I specified it as single threaded by setting param.i_threads = 1. If that is removed, x264 will default to using multiple threads and sets param.i_threads as 1.5x of number of cores in the CPU automatically. This will give faster performance than running in single thread.
But when I remove the param.i_threads = 1 to make it multi-threaded, the output video stream is fully grey. The program works without errors and the encoding time is also faster but I cannot see any output when I view the stream with VLC as its fully grey.
This is the code in which I am streaming the encoded data. This is using the srs librtmp library. There is no error but the stream is showing no output.
for (int j = 0; j < encoder.nal_count; j++)
{
x264_nal_t* nal = encoder.nals + j;
ret = srs_h264_write_raw_frames(rtmp, reinterpret_cast<char*>(nal->p_payload), nal->i_payload, dts, dts);
ret = check_return_value(ret);
if (!ret)
{
return -1;
}
}
Please tell me what is causing this problem when multi-threading is enabled. Am I setting wrong values? Is the code in which I am streaming the encoded data wrong? The encoder works only when it is single threaded. But it should also work when multi-threading is enabled.
OS - Windows 10
CPU - AMD Ryzen 2600
RAM - 16 GB
./configure --disable-cli --enable-shared --extra-ldflags=-Wl,--output-def=libx264.def
I am using the libx264 API in my screen-sharing program with the preset - "veryfast", tune - "zerolatency", profile - "high" and also the following settings.
param.i_csp = X264_CSP_BGRA;
param.i_threads = 1;
param.i_width = width;
param.i_height = height;
param.i_fps_num = fps;
param.i_fps_den = 1;
param.rc.i_bitrate = bitrate;
param.rc.i_rc_method = X264_RC_ABR;
param.rc.b_filler = true;
param.rc.f_rf_constant = (float)0;
param.rc.i_vbv_max_bitrate = param.rc.i_bitrate;
param.rc.i_vbv_buffer_size = param.rc.i_bitrate;
param.b_repeat_headers = 0;
param.b_annexb = 1;
For these settings the program works fine. I specified it as single threaded by setting param.i_threads = 1. If that is removed, x264 will default to using multiple threads and sets param.i_threads as 1.5x of number of cores in the CPU automatically. This will give faster performance than running in single thread.
But when I remove the param.i_threads = 1 to make it multi-threaded, the output video stream is fully grey. The program works without errors and the encoding time is also faster but I cannot see any output when I view the stream with VLC as its fully grey.
This is the code in which I am streaming the encoded data. This is using the srs librtmp library. There is no error but the stream is showing no output.
for (int j = 0; j < encoder.nal_count; j++)
{
x264_nal_t* nal = encoder.nals + j;
ret = srs_h264_write_raw_frames(rtmp, reinterpret_cast<char*>(nal->p_payload), nal->i_payload, dts, dts);
ret = check_return_value(ret);
if (!ret)
{
return -1;
}
}
Please tell me what is causing this problem when multi-threading is enabled. Am I setting wrong values? Is the code in which I am streaming the encoded data wrong? The encoder works only when it is single threaded. But it should also work when multi-threading is enabled.
OS - Windows 10
CPU - AMD Ryzen 2600
RAM - 16 GB