Skip to content
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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

inremen
Copy link

@inremen inremen commented Aug 18, 2020

…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

…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
@coveralls
Copy link

coveralls commented Aug 18, 2020

Coverage Status

Coverage decreased (-0.4%) to 76.488% when pulling 356ab75 on inremen:master into 88639b8 on asticode:master.

Copy link
Owner

@asticode asticode left a 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

subtitles.go Outdated Show resolved Hide resolved
stl.go Outdated Show resolved Hide resolved
stl.go Outdated Show resolved Hide resolved
stl.go Outdated Show resolved Hide resolved
stl.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
teletext.go Outdated Show resolved Hide resolved
… 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
@inremen inremen requested a review from asticode August 21, 2020 06:18
Copy link
Owner

@asticode asticode left a 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

subtitles.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
srt.go Outdated Show resolved Hide resolved
srt.go Outdated Show resolved Hide resolved
srt.go Outdated Show resolved Hide resolved
stl.go Outdated
STLCumulativeStatus: t.cumulativeStatus,
STLExtensionBlockNumber: t.extensionBlockNumber,
STLSubtitleGroupNumber: t.subtitleGroupNumber,
STLText: t.text,
Copy link
Owner

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 ?

Copy link
Author

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

Copy link
Author

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

subtitles.go Outdated Show resolved Hide resolved
stl.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
teletext.go Outdated Show resolved Hide resolved
New attribute Metadata in Item
….stl -t "25s" -o starttime25s.stl or function func (s *Subtitles) ChangeStartTime(starttime time.Duration)
@inremen inremen requested a review from asticode August 24, 2020 12:12
- No read stl subtitles when no lines
teletext.go Outdated Show resolved Hide resolved
webvtt.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
astisub/main.go Outdated Show resolved Hide resolved
astisub/main.go Outdated Show resolved Hide resolved
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 {
Copy link
Owner

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

Copy link
Author

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

Copy link
Owner

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, if t.text comes from i.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)...)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm testing this and the codification changes if we use encodeTextSTL.
Here the example:
ErrorCodificationSTL

Copy link
Owner

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.

Copy link
Author

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

stl.go Show resolved Hide resolved
…opagateWebVTTAttribues in line 194 of webvtt.go
astisub/main.go Show resolved Hide resolved
astisub/main.go Outdated Show resolved Hide resolved
stl.go Outdated Show resolved Hide resolved
subtitles.go Outdated Show resolved Hide resolved
teletext.go Outdated Show resolved Hide resolved
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 {
Copy link
Owner

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, if t.text comes from i.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 {
Copy link
Owner

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"))
Copy link
Owner

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. done

@asticode
Copy link
Owner

asticode commented Sep 2, 2020

Tests are failing :

  1. teletext_test.go:34 : you need to add Metadata: &ItemMetadata{}, line 40 in teletext_test.go
  2. teletext_test.go:78 : you need to add proper WebVTTColor values in each LineItem since you've implemented it
  3. stl_test.go:38 : you need to split the one Write test
    a) create a testdata/example-out-copy.stl file that is going to be the output when copying directly from STLText (which is what's happening in the test now) and test it
    b) then reset each STLText here before testing testdata/example-out.stl

That way we test both copy and encode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants