Add Subtitles asset type#178
Merged
Merged
Conversation
We considered that in future, we might also want to model a Captions asset type. We debated whether a Text asset type would be more generic, but we would then have to add an optional field on the Asset to handle whether it was Captions or Subtitles (which would be awkward as it wouldn't apply to videos and audio). We also discussed how we could model the language of the subtitles. We could model this directly on the Asset, rather than AssetType. A Language field could just as easily apply to Video and Audio as it would to Subtitles. This is not needed for now - but you never know! For these reasons we think going for a Subtitles AssetType is a suitable approach. Co-authored-by: Andy Noton <andy.noton.contractor@guardian.co.uk>
2e864a5 to
ea8c667
Compare
Fweddi
commented
Sep 2, 2025
| AUDIO = 0, | ||
| VIDEO = 1 | ||
| VIDEO = 1, | ||
| SUBTITLES = 2 |
Contributor
Author
There was a problem hiding this comment.
To play devils argument https://www.w3schools.com/tags/att_track_kind.asp shows other 'kinds' of text we could have:
captions | The track defines translation of dialogue and sound effects (suitable for deaf users)
chapters | The track defines chapter titles (suitable for navigating the media resource)
descriptions | The track defines a textual description of the video content (suitable for blind users)
metadata | The track defines content used by scripts. Not visible for the user
subtitles | The track defines subtitles, used to display subtitles in a video
JustinPinner
approved these changes
Sep 2, 2025
Member
JustinPinner
left a comment
There was a problem hiding this comment.
I think this looks safe. The AssetType is a property of MediaAtom, so it is ok to exist in its own right at that level. It extends the existing definition, so that is also safe, and this library must be imported by consumers before it can be effective, so that's safe too. All in all... 👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why are we doing this?
We are adding subtitles to loops. The intended solution is to provide an m3u8 which has an internal reference to a vtt file, but we want to fallback to providing an mp4 alongside the standalone vtt file. To do so we need to extend the AssetType model of the Media atom.
Is this future proof?
We considered that in future, we might also want to model a Captions asset type. We debated whether a Text asset type would be more generic, but we would then have to add an optional field on the Asset to handle whether it was Captions or Subtitles (which would be awkward as it wouldn't apply to videos and audio).
We also discussed how we could model the language of the subtitles. We could model this directly on the Asset, rather than AssetType. A Language field could just as easily apply to Video and Audio as it would to Subtitles. This is not needed for now - but you never know!
For these reasons we think going for a Subtitles AssetType is a suitable approach - it meets the current needs and is future compatible (we can always add a fourth type, Captions, if we ever need to disambiguate between Captions and Subtitles).