Trickplay thumbnails (#169)

* Trickplay thumbnails

* Changelog

* Comment
This commit is contained in:
Brahim Hadriche authored and GitHub committed 2023-10-14 17:36:06 -04:00
1 parent a12b6cca11
commit e80fcabae5
3 files changed
+84 -1

No files matched your search

+2
View File
@@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Local DASH manifest generation
- This adds support for multi languages audio tracks
- Also adds thumbnails/preview in trick play mode
- Known issue: thumbnails might appear cropped/misaligned at the end of videos. This will be addressed in a later release.
### Fixed
@@ -28,6 +28,7 @@ class DashManifest
videoMimeTypes = m.getMimeTypes(videoStreams)
audioSets = m.getMimeTypeLanguageCombos(audioStreams)
storyboards = metadata.storyboards
xml = new XmlObject()
@@ -178,6 +179,85 @@ class DashManifest
id += 1
end for
' 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
interval = ValidInt(storyboard.interval)
if interval = 0
LogWarn("Invalid storyboard interval=0")
continue for
end if
templateUrl = storyboard.templateUrl
if templateUrl.Instr("$M") = -1
LogWarn("Invalid storyboard url: url does not contain $M:", templateUrl)
continue for
end if
storyboardWidth = storyboard.storyboardWidth
storyboardHeight = storyboard.storyboardHeight
storyboardCount = storyboard.storyboardCount
tileWidthInPixels = storyboard.width
tileHeightInPixels = storyboard.height
totalTileCount = storyboard.count
' For the last page, the image height might be smaller than the storyboard height
if storyboardCount = 1
storyboardHeight = totalTileCount \ storyboardWidth
if totalTileCount mod storyboardWidth > 0
storyboardHeight += 1
end if
end if
intervalInSeconds = interval \ 1000
' Youtube template uses the var $M for tile pages
' DASH-IF uses $Number$ in the SegmentTemplate
' https://dashif.org/docs/DASH-IF-IOP-v4.3.pdf
url = templateUrl.replace("$M", "$Number$")
tilesPerPage = storyboardWidth * storyboardHeight
duration = tilesPerPage * intervalInSeconds
storyboardWidthInPixels = tileWidthInPixels * storyboardWidth
storyboardHeightInPixels = tileHeightInPixels * storyboardHeight
' Bandwidth is kind of a guess...
bandwidth = ((storyboardWidthInPixels * storyboardHeightInPixels * 0.5) / duration)
if xml.Node("AdaptationSet", {
"id": `${id}`,
"mimeType": "image/jpeg",
"contentType": "image"
})
xml.Node("SegmentTemplate", {
"media": url,
"duration": duration,
"startNumber": 0
})
xml.End()
if xml.Node("Representation", {
"id": `thumbnails_${id}`,
"bandwidth": bandwidth,
"width": storyboardWidthInPixels,
"height": storyboardHeightInPixels
})
xml.Node("EssentialProperty", {
"schemeIdUri": "http://dashif.org/guidelines/thumbnail_tile",
"value": `${storyboardWidth}x${storyboardHeight}`
})
xml.End()
xml.End()
end if
xml.End()
end if
id += 1
end for
xml.End()
end if
xml.End()
+2 -1
View File
@@ -55,7 +55,8 @@ class XmlObject
if node.attributes <> invalid
for each key in node.attributes.keys()
xmlString += ` ${key}="${node.attributes[key]}"`
value = m.XmlEscape(`${node.attributes[key]}`)
xmlString += ` ${key}="${value}"`
end for
end if