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
When it reads STL files, it generates an array of ttiblocks in the cl… #25
base: master
Are you sure you want to change the base?
Conversation
…ass Subtitles. If we use sync from a stl filel, it changes starttimes in ttiblocks array and it saves the file from ttiblocks instead of Items, mantaining lines properties. It takes account colour and text position converting from STL to VTT. If creattion date and modification date of STL are empty, it continues conversion from STL to VTT
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.
I like the general ideas but this PR needs some changes
… as STLSubtitleGroupNumber, STLExtensionBlockNumber, etc. new function newItemMetadata to intialize - Index attribute moved from Item to ItemMetadata - New types stlVerticalPosition (with function WebVTTPosition) and stlJustification (with function WebVTTLine) code and pointers STLVerticalPosition and STLJustificaationCode of this type in StyleAttributes. This attributes are assigned in function propagateSTLAttributes od subtitles.go - If we save a STL from another STL, for example to sync,we use STL attributtes of ItemMetadata and StyleAttributes to create new TTI blocks
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.
Thanks for the changes, still some changes needed though
stl.go
Outdated
STLCumulativeStatus: t.cumulativeStatus, | ||
STLExtensionBlockNumber: t.extensionBlockNumber, | ||
STLSubtitleGroupNumber: t.subtitleGroupNumber, | ||
STLText: t.text, |
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.
I don't really like this attribute. Does copying []byte makes that much difference ?
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.
Yes. Our subtitle broadcast system uses spaces to center text. So we need to mantain all the bytes when we sync from stl to stl
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.
Besides, colour and size information also goes in this lines
New attribute Metadata in Item
….stl -t "25s" -o starttime25s.stl or function func (s *Subtitles) ChangeStartTime(starttime time.Duration)
- No read stl subtitles when no lines
stl.go
Outdated
o = append(o, t.justificationCode) // Justification code | ||
o = append(o, t.commentFlag) // Comment flag | ||
//if text has 112 characters, copy directly | ||
if len(t.text) == 112 { |
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.
Remove this micro-optimization as you need to compare len(encodeTextSTL(string(t.text))
anyway
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.
If the text is from STL to STL, we dont need to encode. We need to mantain spaces, colour, height, font style that comes in text field
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.
What you're saying makes sense, however I don't like basing the "not encoding" part on the length of t.text
.
Out of simplicity, I'd rather:
- use
encodeTextSTL
here (that way, ift.text
comes fromi.Metadata.STLText
it's never encoded and your spaces, colour, height, etc. are maintained) - remove the
if len(t.text) == 112
and partially revert to
o = append(o, astikit.BytesPad(t.text), '\x8f', 112, astikit.PadRight, astikit.PadCut)...)
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.
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.
This doesn't surprise me since there's this TODO.
However that doesn't change anything for you, if you move encodeTextSTL
here in your case encodeTextSTL
will never get called since you're using i.Metadata.STLText
and therefore codification won't change.
I think this is best for this PR to make this change, and removing encodeTextSTL
in another PR.
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.
I don't understand where I should move encodeTextSTL
…opagateWebVTTAttribues in line 194 of webvtt.go
stl.go
Outdated
o = append(o, t.justificationCode) // Justification code | ||
o = append(o, t.commentFlag) // Comment flag | ||
//if text has 112 characters, copy directly | ||
if len(t.text) == 112 { |
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.
What you're saying makes sense, however I don't like basing the "not encoding" part on the length of t.text
.
Out of simplicity, I'd rather:
- use
encodeTextSTL
here (that way, ift.text
comes fromi.Metadata.STLText
it's never encoded and your spaces, colour, height, etc. are maintained) - remove the
if len(t.text) == 112
and partially revert to
o = append(o, astikit.BytesPad(t.text), '\x8f', 112, astikit.PadRight, astikit.PadCut)...)
- Sync calculation code lines simplified.
stl.go
Outdated
o = append(o, t.justificationCode) // Justification code | ||
o = append(o, t.commentFlag) // Comment flag | ||
//if text has 112 characters, copy directly | ||
if len(t.text) == 112 { |
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.
This doesn't surprise me since there's this TODO.
However that doesn't change anything for you, if you move encodeTextSTL
here in your case encodeTextSTL
will never get called since you're using i.Metadata.STLText
and therefore codification won't change.
I think this is best for this PR to make this change, and removing encodeTextSTL
in another PR.
stl.go
Outdated
for _, l := range i.Lines { | ||
lines = append(lines, l.String()) | ||
} | ||
t.text = []byte(strings.Join(lines, "\n")) |
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.
Replace this line by
t.text = []byte(encodeTextSTL(strings.Join(lines, "\n")))
and check tests still pass
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.
Thanks. done
Tests are failing :
That way we test both copy and encode |
1a6c252
to
012fd3a
Compare
…ass Subtitles. If we use sync from a stl filel, it changes starttimes in ttiblocks array and it saves the file from ttiblocks instead of Items, mantaining lines properties.
It takes account colour and text position converting from STL to VTT.
If creattion date and modification date of STL are empty, it continues conversion from STL to VTT