Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve traffic shaping for the FTL protocol to eliminate video stuttering #1

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions UI/obs-app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1421,13 +1421,28 @@ bool OBSApp::OBSInit()
ResetHotkeyState(state == Qt::ApplicationActive);
});
ResetHotkeyState(applicationState() == Qt::ApplicationActive);

struct tm expiration {};
expiration.tm_year = 2021 - 1900;
expiration.tm_mon = 12 - 1;
expiration.tm_mday = 1;
double timeRemaining = difftime(mktime(&expiration), time(NULL));
blog(LOG_WARNING, "Expirimental build, expires in: %d seconds", timeRemaining);
if (timeRemaining <= 0.0) {
OBSCrashReport expired(mainWindow, "This experimental OBS build has expired, please switch to an official OBS build.");
expired.exec();
return false;
}

return true;
}

string OBSApp::GetVersionString() const
{
stringstream ver;

ver << "- EXPERIMENTAL Glimesh.tv build, expires 2021-12-01 - ";

#ifdef HAVE_OBSCONFIG_H
ver << OBS_VERSION;
#else
Expand Down
2 changes: 1 addition & 1 deletion plugins/obs-outputs/ftl-sdk
39 changes: 6 additions & 33 deletions plugins/obs-outputs/ftl-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,25 +408,6 @@ static int send_packet(struct ftl_stream *stream, struct encoder_packet *packet,

static void set_peak_bitrate(struct ftl_stream *stream)
{
int speedtest_kbps = 15000;
int speedtest_duration = 1000;
speed_test_t results;
ftl_status_t status_code;

status_code = ftl_ingest_speed_test_ex(&stream->ftl_handle,
speedtest_kbps,
speedtest_duration, &results);

float percent_lost = 0;

if (status_code == FTL_SUCCESS) {
percent_lost = (float)results.lost_pkts * 100.f /
(float)results.pkts_sent;
} else {
warn("Speed test failed with: %s",
ftl_status_code_to_string(status_code));
}

// Get what the user set the encoding bitrate to.
obs_encoder_t *video_encoder =
obs_output_get_video_encoder(stream->output);
Expand All @@ -435,20 +416,12 @@ static void set_peak_bitrate(struct ftl_stream *stream)
(int)obs_data_get_int(video_settings, "bitrate");
obs_data_release(video_settings);

// Report the results.
info("Speed test completed: User desired bitrate %d, Peak kbps %d, "
"initial rtt %d, "
"final rtt %d, %3.2f lost packets",
user_desired_bitrate, results.peak_kbps, results.starting_rtt,
results.ending_rtt, percent_lost);

// We still want to set the peak to about 1.2x what the target bitrate is,
// even if the speed test reported it should be lower. If we don't, FTL
// will queue data on the client and start adding latency. If the internet
// connection really can't handle the bitrate the user will see either lost frame
// and recovered frame counts go up, which is reflect in the dropped_frames count.
stream->peak_kbps = stream->params.peak_kbps =
user_desired_bitrate * 12 / 10;
// Set the peak video send bitrate to 1.8x the target bitrate. Video
// traffic can be bursty, the extra headroom helps FTL not buffer packets
// quite as much. If the user's connection can't handle this bitrate they
// will see the dropped frames count go up and can lower the target bitrate.
stream->peak_kbps = stream->params.peak_kbps = user_desired_bitrate * 18 / 10;
blog(LOG_INFO, "Peak kbps (%d)", stream->peak_kbps);
ftl_ingest_update_params(&stream->ftl_handle, &stream->params);
}

Expand Down