From 0ab55456b37086c0990cb282c13bd665a3f33de2 Mon Sep 17 00:00:00 2001 From: TheLegendTubaGuy Date: Tue, 10 Dec 2024 22:48:30 -0600 Subject: [PATCH] Update timecode handling for OBS 31 OBS 31 currently has a bug due to Twitch enhanced broadcasting causing the output duration and timecode to increase by 3.5x. https://github.com/obsproject/obs-websocket/issues/1273 --- script.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/script.js b/script.js index e0f5684..593dc16 100644 --- a/script.js +++ b/script.js @@ -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; @@ -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'; @@ -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]; @@ -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!";