Skip to content

Commit

Permalink
Update timecode handling for OBS 31
Browse files Browse the repository at this point in the history
OBS 31 currently has a bug due to Twitch enhanced broadcasting causing the output duration and timecode to increase by 3.5x.
obsproject/obs-websocket#1273
  • Loading branch information
thelegendtubaguy committed Dec 11, 2024
1 parent 119bbf1 commit 0ab5545
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function connectws() {
activeFps = `${responseData.activeFps.toFixed(1)}`;
const cpu = `${responseData.cpuUsage.toFixed(1)}%`;
const memory = `${responseData.memoryUsage.toFixed(1)}MB`;

const averageFrameRenderTime = `${responseData.averageFrameRenderTime.toFixed(1)}ms`;
const outputSkippedFrames = responseData.outputSkippedFrames;
const outputTotalFrames = responseData.outputTotalFrames;
Expand Down Expand Up @@ -176,7 +176,7 @@ function connectws() {
previousOutputBytes = outputBytes;

document.getElementById("streamBitrateLabel").innerHTML = `${Math.floor(kbps)} kb/s`;
document.getElementById("streamTimecodeLabel").innerHTML = `${RemoveMilliseconds(responseData.outputTimecode)}`;
document.getElementById("streamTimecodeLabel").innerHTML = `${formatMilliseconds(responseData.outputDuration / 3.5)}`;
GetStreamServiceSettings();

document.getElementById("streamingRing").style.visibility = 'visible';
Expand Down Expand Up @@ -238,6 +238,14 @@ function TimeToMilliseconds(hms) {
return totalSeconds * 1000;
}

function formatMilliseconds(ms) {
const hours = Math.floor(ms / (1000 * 60 * 60));
const minutes = Math.floor((ms % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((ms % (1000 * 60)) / 1000);

return `${String(hours).padStart(2, '0')}:${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
}

function RemoveMilliseconds(timecode) {
const parts = timecode.split('.');
return parts[0];
Expand Down Expand Up @@ -367,7 +375,7 @@ function hexToBase64(hexstring) {
// This function sets the visibility of the Streamer.bot status label on the overlay
function SetConnectionStatus(connected) {
let statusContainer = document.getElementById("statusContainer");

if (connected) {
statusContainer.style.background = "#2FB774";
statusContainer.innerText = "Connected!";
Expand Down

0 comments on commit 0ab5545

Please sign in to comment.