-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement tick duration support for TTML subtitles #26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -288,6 +289,10 @@ func (d TTMLInDuration) duration() time.Duration { | |||
if d.framerate > 0 { | |||
return d.d + time.Duration(float64(d.frames)/float64(d.framerate)*1e9)*time.Nanosecond | |||
} | |||
if d.tickrate > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not compute the value once and for all here ? Is the tickrate
value not populated at that time ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, it is not populated at that time.
I created the tests and fixed the styling issues (the alphabetical order). Unfortunately the proper tick duration is still calculated in the duration function. But, I do think this is the only solution. Unmarshalltext only has access to the duration text itself and the tickrate is not known at that time. (I actually wonder if the framerate is accessible as well in that function). Unmarshalltext should in my opinion only be responsible for extracting the text to a proper representation, not for calculating it correctly already. Edit: We need additional work to completely confirm to the TTMLv2 standard though:
|
I do agree with you regarding FYI I've created a Cheers |
I tested it with some examples and it should work. For instance, you can take the example Netflix subtitles:
(Found here: https://netflixtechblog.com/implementing-japanese-subtitles-on-netflix-c165fbe61989 )