cisco / openh264

Open Source H.264 Codec
BSD 2-Clause "Simplified" License
5.54k stars 1.79k forks source link

Question: Right approach to reduce CPU usage? #3621

Closed adydychk closed 1 year ago

adydychk commented 1 year ago

Hello dear openh264 community, I am trying to integrate openh264 encoder to the real-time application. I am satisfied with all metrics (bitrate, avg quality, encode speed) except of CPU usage (as result power usage too). I compare openh264 with x264 encoder in 1280x720, 30 fr and 1500 kbps bitrate scenario. Approximate results:

x264 + some abstractions of application:
- CPU usage 7-13%
- bitrate ~1600

openh264 + some abstractions of application:
- CPU usage 11-19%
- bitrate ~1100

Unfortunately openh264 API is very limited, but I tried following approach to lower CPU usage were:

Can anybody suggest me the right approach? Or is it the maximum of openh264? I will be glad on any feedback :)

My key params for the info:

iRCMode = RC_BITRATE_MODE;
MaxQP = 48
MinQP = 28
iTargetBitrate=1500
iEntropyCodingModeFlag=false
iSkipMode=false
bEnableAdaptiveQuant=false
bEnableDenoise = false;
bEnableBackgroundDetection = false;
bEnableFrameCroppingFlag = false;
bEnableSceneChangeDetect = false;
iMultipleThreadIdc = 1;
bUseLoadBalancing = false;
iComplexityMode = LOW_COMPLEXITY;
eSpsPpsIdStrategy = SPS_LISTING;
iPaddingFlag = 0;

iSpatialLayerNum = 1
sSpatialLayers[0].sSliceArgument.uiSliceMode = SM_SINGLE_SLICE;
sSpatialLayers[0].iDLayerQp = 28;
huili2 commented 1 year ago

Thanks for using. Actually there should not be such gap from our tests. Your above settings are OK, and I hope you add: iUsageType = CAMERA_VIDEO_REAL_TIME; iSpatialLayerNum = 1; besides, does x264 enable multithread?

adydychk commented 1 year ago

Actually there should not be such gap from our tests. You mean CPU usage of openh264 should be close to CPU usage of x264. Yeah?

iUsageType = CAMERA_VIDEO_REAL_TIME; iSpatialLayerNum = 1;

Yes. I use these params.

besides, does x264 enable multithread?

1 thread

Also can you share approximate CPU usage of openh264 (1280x720, 30fr, 1500kbps) in your env/tests? Or is it private information?

LodewijkIVX commented 1 year ago

china/loves/Japan/opium.war/POW?

LodewijkIVX commented 1 year ago

North_South_pipe_line_sabotage?

adydychk commented 1 year ago

@huili2 The reason was in wrong default meson configuration on Windows which does not enable asm optimizations. Any way thanks for the help :)