fix: read the stream quality from HLS variants without FRAME-RATE or CODECS

getStreamInfo returned a resolution only when the top variant of a master playlist had RESOLUTION, FRAME-RATE and CODECS, although playlist:format and playlist:update use only the height. RFC 8216 makes FRAME-RATE and CODECS optional, so such streams never got a quality. The parsing moves to parseStreamInfo, which tests can call without a network.
This commit is contained in:
L4XB
2026-10-25 03:31:03 +01:00
parent f759c62f2e
commit 63ef5bfd76
2 changed files with 52 additions and 3 deletions
+7 -3
View File
@@ -99,8 +99,8 @@ export function truncate(string: string, limit: number = 100) {
type StreamInfo = {
resolution: { width: number; height: number }
bandwidth: number
frameRate: number
codecs: string
frameRate?: number
codecs?: string
}
export async function getStreamInfo(
@@ -162,6 +162,10 @@ export async function getStreamInfo(
if (!data) return undefined
return parseStreamInfo(url, data)
}
export function parseStreamInfo(url: string, data: string): StreamInfo | undefined {
let info: StreamInfo | undefined
if (url.includes('.m3u8')) {
@@ -173,7 +177,7 @@ export async function getStreamInfo(
if (playlist && playlist.isMasterPlaylist && playlist.variants.length) {
const v = orderBy(playlist.variants, ['bandwidth'], ['desc'])[0]
if (v && v.resolution && v.frameRate && v.codecs) {
if (v && v.resolution) {
info = {
resolution: { width: v.resolution.width, height: v.resolution.height },
bandwidth: v.bandwidth,