Skip to content

Add support for importing/exporting SubRip subtitles - #170

Closed
kempniu wants to merge 2 commits into
audacity:masterfrom
kempniu:labels-subrip
Closed

kempniu wants to merge 2 commits into
audacity:masterfrom
kempniu:labels-subrip

Conversation

@kempniu

@kempniu kempniu commented Oct 6, 2016

Copy link
Copy Markdown

As I find Audacity to be a fantastic tool for synchronising text subtitles and there is apparent community interest in adding support for the most common SubRip format, I thought I will give it a shot.

This pull request enables Audacity to both import SubRip subtitles as labels and export labels as SubRip subtitles.

The gotchas I am aware of:

  • My way of integrating SubRip code with current label code is pretty heavy-handed, i.e. extending this code with further input/output formats will not be pleasant. On the other hand, it is not as if there are a dozen of these waiting to be implemented. If you would like to see this done differently, any pointers will be welcome.
  • I had to introduce a variable called sindex and pass it to LabelTrack::Export() so that a valid SubRip subtitle is produced when multiple label tracks are present in a project. Audacity's own label format does not treat this case specially because labels are not assigned sequence numbers of any kind, just start and stop times.
  • The output format used for label export is determined by the extension of the target filename, not the filter index picked by the user in the file selection dialog. This can be misleading, e.g. the user might choose to export labels as SubRip subtitles but then supply a filename ending with .txt, which will result in exporting labels in Audacity's own format. Let me know if you would like this corrected as it would require reworking label export actions so that they use something more sophisticated than FileSelector, which only returns a filename.
  • While it is technically possible for labels to be multi-line, it looks awkward and Audacity is not currently suited for comfortable editing of such subtitles, so I settled for | being a line separator for multi-line subtitles. This should not cause a lot of trouble as | serves as a line separator in other subtitle formats, e.g. MicroDVD (in which case I am pretty sure it is not even escapable).

Finally, my C++ skills are lacking, so if you see something fishy, your gut is probably right.

@JamesCrook

Copy link
Copy Markdown
Contributor

Sorry, this has sat in the queue too long and is now being closed as we couldn't decide on progressing it.

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.

2 participants