From 41a1b0998817eaaac2951a2ce641af4b694081cf Mon Sep 17 00:00:00 2001 From: Richard Stanway Date: Tue, 29 Aug 2017 23:47:52 +0200 Subject: [PATCH] obs-outputs: Improve new netcode if encoder reports 0 bitrate Some encoders such as the AMD AMF encoder don't set their bitrate property, so it gets returned as 0. This causes the new network code to allocate a tiny buffer, resulting in output starvation and throttling to the point of uselessness if low latency mode is also enabled. --- plugins/obs-outputs/rtmp-stream.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/obs-outputs/rtmp-stream.c b/plugins/obs-outputs/rtmp-stream.c index 07dd96d16..d343031ef 100644 --- a/plugins/obs-outputs/rtmp-stream.c +++ b/plugins/obs-outputs/rtmp-stream.c @@ -658,6 +658,14 @@ static int init_send(struct rtmp_stream *stream) obs_data_t *params = obs_encoder_get_settings(vencoder); if (params) { int bitrate = obs_data_get_int(params, "bitrate"); + if (!bitrate) { + warn ("Video encoder didn't return a " + "valid bitrate, new network " + "code may function poorly. " + "Low latency mode disabled."); + stream->low_latency_mode = false; + bitrate = 10000; + } total_bitrate += bitrate; obs_data_release(params); } @@ -668,6 +676,8 @@ static int init_send(struct rtmp_stream *stream) obs_data_t *params = obs_encoder_get_settings(aencoder); if (params) { int bitrate = obs_data_get_int(params, "bitrate"); + if (!bitrate) + bitrate = 160; total_bitrate += bitrate; obs_data_release(params); }