Skip to content

Add support for labels in the SubRip and WebVTT formats - #6139

Merged
LWinterberg merged 3 commits into
audacity:masterfrom
lbordowitz:subrip-labels-v2
Mar 29, 2024
Merged

LWinterberg merged 3 commits into
audacity:masterfrom
lbordowitz:subrip-labels-v2

Conversation

@lbordowitz

@lbordowitz lbordowitz commented Mar 14, 2024 •

Copy link
Copy Markdown

Resolves: #5924

This is a rebase of #394 . The original author is @Pokechu22 and the entirety of this code change should be credited as such.

  • I signed CLA - Pokechu22 did, too
  • The title of the pull request describes an issue it addresses
  • If changes are extensive, then there is a sequence of easily reviewable commits
  • Each commit's message describes its purpose and effects
  • There are no behavior changes unnecessary for the stated purpose of the PR

Recommended:

  • Each commit compiles and runs on my machine without known undesirable changes of behavior

@LWinterberg LWinterberg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good to me overall. There's some more improvements which may be something for the future. As-is, it adds a valuable feature with the label export in a pretty straight-forward manner, which in my book is good for a merge..

Comment thread src/LabelTrack.cpp
{
#ifdef EXPERIMENTAL_SUBRIP_LABEL_FORMATS
if (format == LabelFormat::WEBVTT) {
::AudacityMessageBox( XO("Importing WebVTT files is not currently supported.") );

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would be something to improve in a followup PR. I see that webVTT does some fancy stuff, so the importer would need to be told to strip away everything that we can't deal with, eg.


WEBVTT

STYLE
::cue {
  background-image: linear-gradient(to bottom, dimgray, lightgray);
  color: papayawhip;
}

00:00:00.000 --> 00:00:04.000 position:10%,line-left align:left size:35%
Where did <b>he</b> go?

would need to be converted to

00:00:00.000 --> 00:00:04.000 
Where did <b>he</b> go?

and from there converted to a label.

The tags (<b>, <c>, <i>, <u>, etc) inside the text can stay as they may be things you'd want to set or edit in label form, too - for example to add emphasis to certain words when a character does so too. The style would need to be discarded for the time being.

A second followup would be to make a new exporter for the labels in a similar vein to the Export Audio exporter, which then could have custom fields for styles and such in case of vtt.

Comment thread src/LabelTrack.cpp
Comment on lines +531 to +534
// Parsing data of the form 'HH:MM:SS,sss --> HH:MM:SS,sss'
// Assume that the line is in exactly that format, with no extra whitespace
// and less than 24 hours.
if (timestamp.length() != 29)

@LWinterberg LWinterberg Mar 28, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

While I have never seen a vtt or srt file do anything other than this, I'm a bit uncomfortable with such an assumption. I'd prefer something more robust here. This would also make parsing WebVTT easier.

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.

Labels: Export as subtitle formats

3 participants