Trickplay fix
This commit is contained in:
1 parent
c216714c5b
commit
f3e60c639f
5 files changed
+78
-11
No files matched your search
+3
-1
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Nothing worth mentioning yet.
|
||||
### Fixed
|
||||
|
||||
- Trickplay storyboards on DRM videos
|
||||
|
||||
## [0.43.0] - 2025-10-26
|
||||
|
||||
|
||||
@@ -86,6 +86,19 @@ class DashManifest
|
||||
if xml.Node("Period")
|
||||
|
||||
id = 0
|
||||
id = m.generateAudioAdaptationSets(xml, audioSets, audioStreams, id)
|
||||
id = m.generateVideoAdaptationSets(xml, videoMimeTypes, videoStreams, id)
|
||||
m.generateImageAdaptationSets(xml, storyboards, id)
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
return xml.ToXmlString()
|
||||
end function
|
||||
|
||||
function generateAudioAdaptationSets(xml as object, audioSets as object, audioStreams as object, id as integer) as integer
|
||||
for each audioSet in audioSets
|
||||
adaptationSetAttributes = {
|
||||
"id": `${id}`
|
||||
@@ -154,7 +167,10 @@ class DashManifest
|
||||
|
||||
id += 1
|
||||
end for
|
||||
return id
|
||||
end function
|
||||
|
||||
function generateVideoAdaptationSets(xml as object, videoMimeTypes as object, videoStreams as object, id as integer) as integer
|
||||
for each mimeType in videoMimeTypes
|
||||
if xml.Node("AdaptationSet", {
|
||||
"id": `${id}`
|
||||
@@ -223,9 +239,13 @@ class DashManifest
|
||||
|
||||
id += 1
|
||||
end for
|
||||
return id
|
||||
end function
|
||||
|
||||
function generateImageAdaptationSets(xml as object, storyboards as object, id as integer) as integer
|
||||
' https://developer.roku.com/en-ca/docs/developer-program/media-playback/trick-mode/hls-and-dash.md#dash-standard-thumbnail-tiles
|
||||
for each storyboard in storyboards
|
||||
for i = storyboards.Count() - 1 to 0 step -1
|
||||
storyboard = storyboards[i]
|
||||
interval = ValidInt(storyboard.interval)
|
||||
if interval = 0
|
||||
LogWarnNoTelemetry("Invalid storyboard interval:", storyboard.interval)
|
||||
@@ -294,13 +314,7 @@ class DashManifest
|
||||
|
||||
id += 1
|
||||
end for
|
||||
|
||||
xml.End()
|
||||
end if
|
||||
xml.End()
|
||||
end if
|
||||
|
||||
return xml.ToXmlString()
|
||||
return id
|
||||
end function
|
||||
|
||||
function getAudioStreams(streams as object) as object
|
||||
|
||||
@@ -147,7 +147,10 @@ function CreateStreamUrls(metadata as object, service as Invidious.InvidiousServ
|
||||
streamUrls = []
|
||||
|
||||
if SupportsDrmDashManifest(metadata)
|
||||
streamUrls.push(metadata.dashUrl)
|
||||
dashUrl = UrlUtils.AppendQueryParams(`http://127.0.0.1:${playletServerPort}/api/dash`, {
|
||||
url: metadata.dashUrl
|
||||
})
|
||||
streamUrls.push(dashUrl)
|
||||
else if SupportsHls(metadata)
|
||||
metadata.hlsUrl = AddInstanceToUrlIfNeeded(metadata.hlsUrl, instance)
|
||||
AddHlsUrls(streamUrls, metadata, preferredQuality, backend, proxyVideos, playletServerPort)
|
||||
|
||||
@@ -23,6 +23,11 @@ namespace Http
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
url = request.query.url
|
||||
if not StringUtils.IsNullOrEmpty(url)
|
||||
return m.GenerateDashManifestAppendStoryboards(context)
|
||||
end if
|
||||
|
||||
v = request.query.v
|
||||
local = request.query.local
|
||||
quality = request.query.quality
|
||||
@@ -80,6 +85,46 @@ namespace Http
|
||||
return qualityFilter
|
||||
end function
|
||||
|
||||
function GenerateDashManifestAppendStoryboards(context as object) as boolean
|
||||
request = context.request
|
||||
response = context.response
|
||||
|
||||
url = request.query.url
|
||||
|
||||
storyboards = ObjectUtils.DigUnsafe(m.videoQueueNode, ["player", "content", "metadata", "storyboards"])
|
||||
if not IsArray(storyboards) or storyboards.count() = 0
|
||||
response.Redirect(url)
|
||||
return true
|
||||
end if
|
||||
|
||||
dashRequest = HttpClient.Get(url)
|
||||
dashResponse = dashRequest.Await()
|
||||
|
||||
if not dashResponse.IsSuccess()
|
||||
LogError("Failed to fetch DASH manifest from URL", dashResponse.ErrorMessage())
|
||||
response.Redirect(url)
|
||||
return true
|
||||
end if
|
||||
|
||||
dashContent = ValidString(dashResponse.Text())
|
||||
storyboardIndex = dashContent.InStr("</Period>")
|
||||
if storyboardIndex = -1
|
||||
response.Redirect(url)
|
||||
return true
|
||||
end if
|
||||
|
||||
xml = new XmlObject()
|
||||
manifestObj = new DashManifest("")
|
||||
manifestObj.generateImageAdaptationSets(xml, storyboards, 100)
|
||||
storyboardXml = xml.ToXmlString(false)
|
||||
|
||||
newDashContent = dashContent.Left(storyboardIndex) + storyboardXml + dashContent.Mid(storyboardIndex)
|
||||
response.http_code = 200
|
||||
response.SetBodyDataString(newDashContent)
|
||||
response.ContentType("application/dash+xml")
|
||||
return true
|
||||
end function
|
||||
|
||||
end class
|
||||
|
||||
end namespace
|
||||
@@ -64,8 +64,11 @@ class XmlObject
|
||||
end if
|
||||
end function
|
||||
|
||||
function ToXmlString() as string
|
||||
function ToXmlString(header = true as boolean) as string
|
||||
xml = ""
|
||||
if header
|
||||
xml = `<?xml version="1.0" encoding="UTF-8"?>\n`
|
||||
end if
|
||||
for each item in m.prolog
|
||||
if item.type = "comment"
|
||||
xml += `<!-- ${item.comment} -->\n`
|
||||
|
||||
Reference in new issue
Block a user