Created
April 9, 2024 18:32
-
-
Save Sean-Der/7b5a1dc74b24aa816bf0f301f0c672f3 to your computer and use it in GitHub Desktop.
OBS Patch for Pacing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/plugins/obs-webrtc/whip-output.cpp b/plugins/obs-webrtc/whip-output.cpp | |
index e83cc03b8..0e3693992 100644 | |
--- a/plugins/obs-webrtc/whip-output.cpp | |
+++ b/plugins/obs-webrtc/whip-output.cpp | |
@@ -60,6 +60,10 @@ bool WHIPOutput::Start() | |
return false; | |
} | |
+ obs_data_t *video_settings = obs_encoder_get_settings(encoder); | |
+ video_bitrate = (int)obs_data_get_int(video_settings, "bitrate"); | |
+ obs_data_release(video_settings); | |
+ | |
is_av1 = (strcmp("av1", obs_encoder_get_codec(encoder)) == 0); | |
if (!obs_output_can_begin_data_capture(output, 0)) | |
@@ -161,7 +165,13 @@ void WHIPOutput::ConfigureVideoTrack(std::string media_stream_id, | |
} | |
video_sr_reporter = std::make_shared<rtc::RtcpSrReporter>(rtp_config); | |
+ | |
packetizer->addToChain(video_sr_reporter); | |
+ if (video_bitrate != 0) { | |
+ packetizer->addToChain(std::make_shared<rtc::PacingHandler>( | |
+ static_cast<float>(video_bitrate * 1000), | |
+ std::chrono::milliseconds(5))); | |
+ } | |
packetizer->addToChain(std::make_shared<rtc::RtcpNackResponder>()); | |
video_track = peer_connection->addTrack(video_description); | |
diff --git a/plugins/obs-webrtc/whip-output.h b/plugins/obs-webrtc/whip-output.h | |
index 2933dfae6..954150a59 100644 | |
--- a/plugins/obs-webrtc/whip-output.h | |
+++ b/plugins/obs-webrtc/whip-output.h | |
@@ -44,6 +44,7 @@ private: | |
obs_output_t *output; | |
bool is_av1; | |
+ int video_bitrate; | |
std::string endpoint_url; | |
std::string bearer_token; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment