Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Always include "Source" in the source stream's quality string because…
Browse files Browse the repository at this point in the history
… of Twitch API weirdness.

Distinguishes between 720p60 (source) and 720p30 (transcoded) when framerates are not included in the M3U8 response.
ScrubN committed Jan 21, 2024
1 parent c19f9c8 commit 51becdf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions TwitchDownloaderCore/Extensions/M3U8Extensions.cs
Original file line number Diff line number Diff line change
@@ -108,19 +108,34 @@ public static string GetResolutionFramerateString(this M3U8.Stream stream)

if (streamInfo.Resolution == default)
{
if (stream.IsSource())
{
return "Source";
}

return "";
}

var frameHeight = streamInfo.Resolution.Height;

if (streamInfo.Framerate == default)
{
if (stream.IsSource())
{
return $"{frameHeight}p (Source)";
}

return $"{frameHeight}p";
}

// Some M3U8 responses have framerate values up to 2fps more/less than the typical framerate.
var frameRate = (uint)(Math.Round(streamInfo.Framerate / 10) * 10);

if (stream.IsSource())
{
return $"{frameHeight}p{frameRate} (Source)";
}

return $"{frameHeight}p{frameRate}";
}

0 comments on commit 51becdf

Please sign in to comment.