Skip to content

Add support for labels in the SubRip and WebVTT formats#394

Closed
Pokechu22 wants to merge 3 commits intoaudacity:masterfrom
Pokechu22:subrip-labels-v2
Closed

Add support for labels in the SubRip and WebVTT formats#394
Pokechu22 wants to merge 3 commits intoaudacity:masterfrom
Pokechu22:subrip-labels-v2

Conversation

@Pokechu22
Copy link
Copy Markdown
Contributor

Allows exporting labels in the SubRip and WebVTT formats (and importing labels in SubRip format as well, but not WebVTT). This is a resubmission of #383 that has been cleaned up a ton. There's a wiki article on the use for this.

Improvements from before:

  • Split into 3 commits to make it easier to review (mainly because of indentation changes)
  • The new formats are controlled by EXPERIMENTAL_SUBRIP_LABEL_FORMATS (and I've made sure that everything compiles with it enabled and with it disabled)
  • Timestamps are parsed using wxDateTime, based on what @kempniu did in Add support for importing/exporting SubRip subtitles #170.
  • Deciding which format to use now happens in a single method (LabelTrack::FormatForFileName) so only one place needs to be modified, instead of 4 locations in 2 files.
  • I've fixed all of the references to "WebVVT" and replaced them with "WebVTT" (that took me an embarrassingly long time to notice). "VTT" stands for "Video Text Tracks".

There are a few known issues:

  • WebVTT files cannot be imported. The format is much more complicated (see the spec) and supports content that does not directly translate into labels (such as comments which are not displayed and do not have a timestamp, and regions that indicate positioning of cues).
  • Both SubRip and WebVTT support multiple lines in a cue, but labels do not currently support multiple lines (and the current txt format doesn't have the ability to do it). When importing SubRip files, I simply join the lines with spaces. (Add support for importing/exporting SubRip subtitles #170 used | based on MicroDVD, which I have no experience with.)
  • Exporting multiple tracks at the same time leads to an invalid file — it effectively concatenates what happens if you export each individually. The identifier (which is just a counter here) is reset to 1 for each file, and the WEBVTT header is repeated. Although both of those are fixable, WebVTT also requires that the start time "must be greater than or equal to the start time offsets of all previous cues in the file" (§4.1, "WebVTT cue timings"). Resolving that requires merging the two files in sorted order and that would require a more substantial rework of how label track I/O works (which would be good eventually, as the labels editor would also be sorted by timestamp instead of track and then timestamp).

@JamesCrook JamesCrook added the Enhancement Request Or feature requests. Open-ended requests are better suited for discussions. label Nov 24, 2019
@Pokechu22
Copy link
Copy Markdown
Contributor Author

Rebased to fix conflicts with aa39f9a. It seems a bit odd to have both LabelTrack::SubripFiles (a FileNames::FileType) and the LabelFormat enum, but it doesn't look like FileNames::SelectFile returns the selected type so it can't directly be used as far as I can tell.

@LWinterberg
Copy link
Copy Markdown
Member

Hey, this is a feature I care about! I can't believe I missed this PR until now. @Pokechu22 Can you rebase this PR onto latest master?

@LWinterberg
Copy link
Copy Markdown
Member

an updated version got merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement Request Or feature requests. Open-ended requests are better suited for discussions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants