Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 14th July 2020, 12:36   #1  |  Link
cool man
Registered User
 
Join Date: Jun 2020
Posts: 1
x264 output video is blank when threading is enabled

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

Code:
./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.
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 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.

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? 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
cool man is offline   Reply With Quote
Reply

Tags
c++, libx264, multi-threading, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 18:40.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.