I am using libx264 compiled from source. It was configured to get both libx264.dll and libx264.lib by this command

Code:
./configure --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.
Code:
        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 final output stream is fully grey. The program works without any errors but I cannot see any output when I view the stream with VLC as it is grey.

This is the code in which I am streaming the encoded data. This is using the srs librtmp library. There is no error in this code but the stream has no output.
Code:
            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? It works in single thread so it should also work in multiple threads. But it is not working. What is wrong here?