OBS is using only 7 out of 20 cpu cores?

prgmitchell

Forum Moderator
Okay, I am not able to check anything at the moment but there is someone else in the thread saying they are not experiencing the same so it is likely a configuration issue.
 

MrStevee

New Member
I also tested an older version of OBS.
But only in portable mode.
This one didn't have any major settings. Except for the output settings.
It also had the same problem with the cores.
 

DeMoN

Member
Please, attach your OBS log file where the issue is present (full log file, with the profiler data).
It wont show that OBS uses only 7 Cores I think. But its not my issue. I cant even test (properly), my cpu has only 8 cores.
Stevee did upload a log earlier already
Have you tried running it with different CPU affinity parameters in the task manager?
There are all cores selected. It wont magically use more cpu cores by disabling affinity cores.
 

Suslik V

Active Member
@DeMoN the idea behind posting the log was to check for performance issues if they are present somewhere else. The log from @MrStevee just shows perfect "video_thread(video) ...99th percentile=1.833 ms" for 60 fps. There is no lag in the log - nothing to fix or recommend.

Anyway, if you are want to use custom options, here is example how it may look, edge case (example itself only for demonstration and has no real meaning):

Type: Custom Output (FFmpeg), libx264 encoder, 25 FPS, 2 core CPU
Encoding overloaded. 1 thread. The "Video Encoder Settings" string --> preset=slower crf=15 threads=1 x264-params=b-adapt=0:bframes=0:rc-lookahead=20
Code:
09:39:20.767: ==== Recording Stop ================================================
09:39:20.768: Video stopped, number of skipped frames due to encoding lag: 111/3039 (3.7%)
...
09:39:42.451: == Profiler Results =============================
09:39:42.451: run_program_init: 6313.14 ms
...
09:39:42.452: obs_graphics_thread(40 ms): min=0.036 ms, median=3.298 ms, max=1734.11 ms, 99th percentile=12.679 ms, 99.9756% below 40 ms
09:39:42.452:  ┣tick_sources: min=0.001 ms, median=0.054 ms, max=1733.75 ms, 99th percentile=0.131 ms
09:39:42.452:  ┣output_frame: min=0.028 ms, median=2.041 ms, max=10.114 ms, 99th percentile=6.079 ms
09:39:42.452:  ┃ ┣gs_context(video->graphics): min=0.028 ms, median=1.891 ms, max=10.114 ms, 99th percentile=4.486 ms
09:39:42.452:  ┃ ┃ ┣render_video: min=0.008 ms, median=1.174 ms, max=9.623 ms, 99th percentile=2.769 ms
09:39:42.452:  ┃ ┃ ┃ ┣render_main_texture: min=0.004 ms, median=1.143 ms, max=9.618 ms, 99th percentile=2.724 ms
09:39:42.452:  ┃ ┃ ┃ ┣render_convert_texture: min=0.011 ms, median=0.012 ms, max=1.674 ms, 99th percentile=0.037 ms, 0.742188 calls per parent call
09:39:42.452:  ┃ ┃ ┃ ┗stage_output_texture: min=0.003 ms, median=0.008 ms, max=0.091 ms, 99th percentile=0.018 ms, 0.742188 calls per parent call
09:39:42.452:  ┃ ┃ ┣gs_flush: min=0.016 ms, median=0.418 ms, max=7.605 ms, 99th percentile=2.313 ms
09:39:42.452:  ┃ ┃ ┗download_frame: min=0 ms, median=0.007 ms, max=0.848 ms, 99th percentile=0.017 ms, 0.742188 calls per parent call
09:39:42.452:  ┃ ┗output_video_data: min=0.001 ms, median=0.049 ms, max=6.343 ms, 99th percentile=1.653 ms, 0.741943 calls per parent call
09:39:42.452:  ┗render_displays: min=0 ms, median=0.883 ms, max=18.878 ms, 99th percentile=9.974 ms
09:39:42.452: video_thread(video): min=0.432 ms, median=30.42 ms, max=207.788 ms, 99th percentile=103.456 ms
MediaInfo report: Encoding settings: ...chroma_qp_offset=-2 / threads=1 / lookahead_threads=1 / sliced_threads=0...

OK. 2 threads. The "Video Encoder Settings" string --> preset=slower crf=15 threads=2 x264-params=b-adapt=0:bframes=0:rc-lookahead=20
Code:
09:44:35.929: ==== Recording Stop ================================================
...
09:44:52.849: == Profiler Results =============================
09:44:52.849: run_program_init: 6332.3 ms

09:44:52.849: obs_hotkey_thread(25 ms): min=0.002 ms, median=0.005 ms, max=26.547 ms, 99th percentile=0.162 ms, 99.9862% below 25 ms
09:44:52.849: audio_thread(Audio): min=0.035 ms, median=0.737 ms, max=12.951 ms, 99th percentile=2.45 ms
09:44:52.849: obs_graphics_thread(40 ms): min=0.038 ms, median=3.694 ms, max=1852.22 ms, 99th percentile=18.155 ms, 99.9778% below 40 ms
09:44:52.849:  ┣tick_sources: min=0.001 ms, median=0.055 ms, max=1847.07 ms, 99th percentile=0.125 ms
09:44:52.850:  ┣output_frame: min=0.028 ms, median=1.658 ms, max=26.775 ms, 99th percentile=9.818 ms
09:44:52.850:  ┃ ┣gs_context(video->graphics): min=0.028 ms, median=1.529 ms, max=20.891 ms, 99th percentile=3.355 ms
09:44:52.850:  ┃ ┃ ┣render_video: min=0.008 ms, median=1.1 ms, max=14.658 ms, 99th percentile=2.383 ms
09:44:52.850:  ┃ ┃ ┃ ┣render_main_texture: min=0.003 ms, median=1.07 ms, max=14.616 ms, 99th percentile=2.366 ms
09:44:52.850:  ┃ ┃ ┃ ┣render_convert_texture: min=0.011 ms, median=0.013 ms, max=0.114 ms, 99th percentile=0.037 ms, 0.672945 calls per parent call
09:44:52.850:  ┃ ┃ ┃ ┗stage_output_texture: min=0.002 ms, median=0.008 ms, max=1.795 ms, 99th percentile=0.018 ms, 0.672945 calls per parent call
09:44:52.850:  ┃ ┃ ┣gs_flush: min=0.019 ms, median=0.422 ms, max=13.753 ms, 99th percentile=1.093 ms
09:44:52.850:  ┃ ┃ ┗download_frame: min=0 ms, median=0.006 ms, max=0.117 ms, 99th percentile=0.016 ms, 0.672945 calls per parent call
09:44:52.850:  ┃ ┗output_video_data: min=0.041 ms, median=0.05 ms, max=25.345 ms, 99th percentile=10.131 ms, 0.672723 calls per parent call
09:44:52.850:  ┗render_displays: min=0 ms, median=1.718 ms, max=29.633 ms, 99th percentile=13.69 ms
09:44:52.850: OBSBasic::ResetOutputs: 1.803 ms
09:44:52.850: video_thread(video): min=0.217 ms, median=0.276 ms, max=83.963 ms, 99th percentile=35.649 ms
MediaInfo report: Encoding settings: ...chroma_qp_offset=-2 / threads=2 / lookahead_threads=1 / sliced_threads=0...

Type: Standard. x264 encoder, 25 FPS, 2 core CPU
Encoding overloaded. 1 thread. Rate Control: CRF. CPU Usage Preset: slower. The "x264 Options" string --> b-adapt=0 bframes=0 rc-lookahead=20 threads=1
Code:
10:06:56.464: [x264 encoder: 'advanced_video_recording'] custom settings:
10:06:56.464:     b-adapt = 0
10:06:56.464:     bframes = 0
10:06:56.464:     rc-lookahead = 20
10:06:56.464:     threads = 1
...
10:08:59.455: ==== Recording Stop ================================================
10:08:59.457: Video stopped, number of skipped frames due to encoding lag: 113/3069 (3.7%)
...
10:09:08.267: == Profiler Results =============================
10:09:08.267: run_program_init: 6344.17 ms
...
10:09:08.268: obs_graphics_thread(40 ms): min=0.017 ms, median=3.259 ms, max=1747.02 ms, 99th percentile=12.881 ms, 99.9725% below 40 ms
10:09:08.268:  ┣tick_sources: min=0.001 ms, median=0.054 ms, max=1746.9 ms, 99th percentile=0.146 ms
10:09:08.268:  ┣output_frame: min=0.013 ms, median=2.45 ms, max=10.91 ms, 99th percentile=6.708 ms
10:09:08.268:  ┃ ┣gs_context(video->graphics): min=0.013 ms, median=2.398 ms, max=10.27 ms, 99th percentile=5.461 ms
10:09:08.268:  ┃ ┃ ┣render_video: min=0.002 ms, median=1.977 ms, max=9.789 ms, 99th percentile=2.925 ms
10:09:08.268:  ┃ ┃ ┃ ┣render_main_texture: min=0.001 ms, median=1.95 ms, max=9.761 ms, 99th percentile=2.864 ms
10:09:08.268:  ┃ ┃ ┃ ┣render_convert_texture: min=0.011 ms, median=0.013 ms, max=0.848 ms, 99th percentile=0.039 ms, 0.844567 calls per parent call
10:09:08.268:  ┃ ┃ ┃ ┗stage_output_texture: min=0.002 ms, median=0.007 ms, max=4.61 ms, 99th percentile=0.019 ms, 0.844567 calls per parent call
10:09:08.268:  ┃ ┃ ┣gs_flush: min=0.01 ms, median=0.44 ms, max=7.579 ms, 99th percentile=2.302 ms
10:09:08.268:  ┃ ┃ ┗download_frame: min=0 ms, median=0.007 ms, max=0.189 ms, 99th percentile=0.016 ms, 0.844567 calls per parent call
10:09:08.268:  ┃ ┗output_video_data: min=0.001 ms, median=0.05 ms, max=7.543 ms, 99th percentile=2.175 ms, 0.844292 calls per parent call
10:09:08.268:  ┗render_displays: min=0 ms, median=0.785 ms, max=15.11 ms, 99th percentile=10.022 ms
10:09:08.268: video_thread(video): min=0.371 ms, median=30.793 ms, max=239.317 ms, 99th percentile=101.216 ms
10:09:08.268:  ┗receive_video: min=0.365 ms, median=30.727 ms, max=89.084 ms, 99th percentile=66.91 ms
10:09:08.268:    ┗do_encode: min=0.364 ms, median=30.726 ms, max=89.083 ms, 99th percentile=66.909 ms
10:09:08.268:      ┣encode(advanced_video_recording): min=0.321 ms, median=30.659 ms, max=89.045 ms, 99th percentile=66.871 ms
10:09:08.268:      ┗send_packet: min=0.008 ms, median=0.028 ms, max=4.786 ms, 99th percentile=0.158 ms
MediaInfo report: Encoding settings: ...chroma_qp_offset=-2 / threads=1 / lookahead_threads=1 / sliced_threads=0...

OK. 2 threads. Rate Control: CRF. CPU Usage Preset: slower. The "x264 Options" string --> b-adapt=0 bframes=0 rc-lookahead=20 threads=2
Code:
10:34:17.950: [x264 encoder: 'advanced_video_recording'] custom settings:
10:34:17.950:     b-adapt = 0
10:34:17.950:     bframes = 0
10:34:17.950:     rc-lookahead = 20
10:34:17.950:     threads = 2
...
10:36:20.653: ==== Recording Stop ================================================
...
10:36:28.223: == Profiler Results =============================
10:36:28.223: run_program_init: 8204.02 ms
...
10:36:28.224: obs_graphics_thread(40 ms): min=0.037 ms, median=2.856 ms, max=1750.55 ms, 99th percentile=12.653 ms, 99.9803% below 40 ms
10:36:28.224:  ┣tick_sources: min=0.001 ms, median=0.102 ms, max=1746.51 ms, 99th percentile=0.219 ms
10:36:28.224:  ┣output_frame: min=0.029 ms, median=0.729 ms, max=43.076 ms, 99th percentile=4.907 ms
10:36:28.224:  ┃ ┣gs_context(video->graphics): min=0.029 ms, median=0.727 ms, max=43.075 ms, 99th percentile=3.976 ms
10:36:28.224:  ┃ ┃ ┣render_video: min=0.009 ms, median=0.139 ms, max=10.026 ms, 99th percentile=2.075 ms
10:36:28.224:  ┃ ┃ ┃ ┣render_main_texture: min=0.004 ms, median=0.129 ms, max=10.015 ms, 99th percentile=2.045 ms
10:36:28.224:  ┃ ┃ ┃ ┣render_convert_texture: min=0.011 ms, median=0.012 ms, max=0.105 ms, 99th percentile=0.036 ms, 0.120781 calls per parent call
10:36:28.224:  ┃ ┃ ┃ ┗stage_output_texture: min=0.002 ms, median=0.007 ms, max=0.1 ms, 99th percentile=0.017 ms, 0.120781 calls per parent call
10:36:28.224:  ┃ ┃ ┣gs_flush: min=0.018 ms, median=0.573 ms, max=39.729 ms, 99th percentile=3.517 ms
10:36:28.224:  ┃ ┃ ┗download_frame: min=0 ms, median=0.007 ms, max=0.601 ms, 99th percentile=0.015 ms, 0.120781 calls per parent call
10:36:28.224:  ┃ ┗output_video_data: min=0.041 ms, median=0.049 ms, max=25.354 ms, 99th percentile=9.363 ms, 0.120741 calls per parent call
10:36:28.224:  ┗render_displays: min=0 ms, median=1.938 ms, max=78.442 ms, 99th percentile=8.966 ms
10:36:28.224: OBSBasic::ResetOutputs: 754.242 ms
10:36:28.224: video_thread(video): min=0.208 ms, median=0.246 ms, max=85.091 ms, 99th percentile=37.719 ms
10:36:28.224:  ┗receive_video: min=0.207 ms, median=0.243 ms, max=85.089 ms, 99th percentile=37.717 ms
10:36:28.224:    ┗do_encode: min=0.206 ms, median=0.241 ms, max=85.089 ms, 99th percentile=37.716 ms
10:36:28.224:      ┣encode(advanced_video_recording): min=0.182 ms, median=0.21 ms, max=82.853 ms, 99th percentile=37.023 ms
10:36:28.224:      ┗send_packet: min=0.006 ms, median=0.022 ms, max=10.777 ms, 99th percentile=5.887 ms
MediaInfo report: Encoding settings: ...chroma_qp_offset=-2 / threads=2 / lookahead_threads=1 / sliced_threads=0...

-------------------------------------------------------

The media file encoded with x264 encoder has "Encoding settings" string that may show to you number of threads used during encoding if you drop this media file into MediaInfo application. The x264 defaults to x1.5 threads per CPU core. CPU tested in this example has 2 cores (real cores). Thus, if you are using default settings in OBS for this CPU you have 3 threads only - MediaInfo: Encoding settings: ...chroma_qp_offset=-2 / threads=3 / lookahead_threads=1 / sliced_threads=0... and this is far than enough for this model of CPU.
 

DeMoN

Member
@DeMoN the idea behind posting the log was to check for performance issues if they are present somewhere else. The log from @MrStevee just shows perfect "video_thread(video) ...99th percentile=1.833 ms" for 60 fps. There is no lag in the log - nothing to fix or recommend.
Please read the thread guys
yes it works with x264 preset "fast", but he could use Preset "slow" when it would use more cores. The cpu is that fast.

Preset fast, preset medium, preset slow with the only extra parameter being CRF - all use all cpu cores in ffmpeg.exe. Just in OBS not

commandline in OBS was posted too

Preset=fast crf=15

and yes mediainfo shows 43 Threads just like ffmpeg.exe. Its not about the x264 encoder or the threads, its OBS somehow assigning only 7 cores to encode
 

Suslik V

Active Member
mediainfo shows 43 Threads...
There are all cores selected...
...OBS somehow assigning only 7 cores to encode
Yeah. 43 threads and only 7 of 20 cores used = bottleneck somewhere in this setup. I hope you will find it and share results.

Side note.
Somehow users usually forgets that OBS is not transcoder tool. OBS works in real-time. OBS has limited time window for the frame to arrive and depart. An "Overload" during transcoding is not possible because it is time dependent thing. Users usually using 4k resolutions at max rendering rate, plugs M2 drives to the same express bus where video card connected, applying a lot of filters, and running medias and then expects that they can feed theirs CPUs with all this data when almost no transfer room left. My oh my.
 

rockbottom

Active Member
I don't seem to have that issue. OBS v30.2.2

View attachment 110892

Okay, I am not able to check anything at the moment but there is someone else in the thread saying they are not experiencing the same so it is likely a configuration issue.

Yeah. 43 threads and only 7 of 20 cores used = bottleneck somewhere in this setup. I hope you will find it and share results.

Side note.
Somehow users usually forgets that OBS is not transcoder tool. OBS works in real-time. OBS has limited time window for the frame to arrive and depart. An "Overload" during transcoding is not possible because it is time dependent thing. Users usually using 4k resolutions at max rendering rate, plugs M2 drives to the same express bus where video card connected, applying a lot of filters, and running medias and then expects that they can feed theirs CPUs with all this data when almost no transfer room left. My oh my.
 

DeMoN

Member
OBS would have enough time if it would use more cpu cores.
This cpu encodes 150 fps at preset slow, we need just 60. OBS is below 60 because it uses just 7 cores of this cpu.
 
Top