From a3b3a143a5df8ebd804df74d0a732d8d819a25bc Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Sat, 13 Jan 2024 14:49:10 -0500 Subject: [PATCH] Add colorInfo to dash --- CHANGELOG.md | 4 ++ .../components/Services/Dash/DashManifest.bs | 65 +++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a56f138d..7308937e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +Nothing worth mentioning yet. + ## [0.19.1] - 2024-01-13 ### Added diff --git a/playlet-lib/src/components/Services/Dash/DashManifest.bs b/playlet-lib/src/components/Services/Dash/DashManifest.bs index 63e4732c..6c6d4076 100644 --- a/playlet-lib/src/components/Services/Dash/DashManifest.bs +++ b/playlet-lib/src/components/Services/Dash/DashManifest.bs @@ -10,6 +10,24 @@ class DashManifest function new(invidiousInstance as string) m.utils = new Http.Utils() m.invidiousInstance = invidiousInstance + + ' https://github.com/LuanRT/YouTube.js/blob/6082b4a52ee07a622735e6e9128a0531a5ae3bfb/src/utils/StreamingInfo.ts#L332-L349 + m.colorInfo = { + primaries: { + "COLOR_PRIMARIES_BT709": "1" + "COLOR_PRIMARIES_BT2020": "9" + } + transferCharacteristics: { + "COLOR_TRANSFER_CHARACTERISTICS_BT709": "1" + "COLOR_TRANSFER_CHARACTERISTICS_BT2020_10": "14" + "COLOR_TRANSFER_CHARACTERISTICS_SMPTEST2084": "16" + "COLOR_TRANSFER_CHARACTERISTICS_ARIB_STD_B67": "18" + } + matrixCoefficients: { + "COLOR_MATRIX_COEFFICIENTS_BT709": "1" + "COLOR_MATRIX_COEFFICIENTS_BT2020_NCL": "14" + } + } end function function fromVideoMetadata(metadata as object, local as boolean) as string @@ -154,6 +172,7 @@ class DashManifest end if if xml.Node("Representation", representationAttributes) + m.AddColorInfo(stream, xml) if xml.Node("BaseURL") xml.Text(stream.url) xml.End() @@ -371,4 +390,50 @@ class DashManifest end for return result end function + + function AddColorInfo(videoStream as object, xml as object) as void + if videoStream.colorInfo = invalid + return + end if + + if videoStream.colorInfo.primaries <> invalid + primaries = m.colorInfo.primaries[videoStream.colorInfo.primaries] + if primaries <> invalid + xml.Node("EssentialProperty", { + "schemeIdUri": "urn:mpeg:mpegB:cicp:ColourPrimaries" + "value": primaries + }) + xml.End() + else + LogWarn("Unknown colorInfo.primaries:", videoStream.colorInfo.primaries) + end if + end if + + if videoStream.colorInfo.transferCharacteristics <> invalid + transferCharacteristics = m.colorInfo.transferCharacteristics[videoStream.colorInfo.transferCharacteristics] + if transferCharacteristics <> invalid + xml.Node("EssentialProperty", { + "schemeIdUri": "urn:mpeg:mpegB:cicp:TransferCharacteristics" + "value": transferCharacteristics + }) + xml.End() + else + LogWarn("Unknown colorInfo.transferCharacteristics:", videoStream.colorInfo.transferCharacteristics) + end if + end if + + if videoStream.colorInfo.matrixCoefficients <> invalid + matrixCoefficients = m.colorInfo.matrixCoefficients[videoStream.colorInfo.matrixCoefficients] + if matrixCoefficients <> invalid + xml.Node("EssentialProperty", { + "schemeIdUri": "urn:mpeg:mpegB:cicp:MatrixCoefficients" + "value": matrixCoefficients + }) + xml.End() + else + LogWarn("Unknown colorInfo.matrixCoefficients:", videoStream.colorInfo.matrixCoefficients) + end if + end if + end function + end class