weizhenye / ass-compiler

Parses and compiles ASS subtitle format to easy-to-use data structure
https://ass.js.org/ass-compiler/
MIT License
107 stars 18 forks source link

An option to not parse time #17

Closed TheJanusz closed 3 months ago

TheJanusz commented 3 months ago

I am curious about the rationale for parsing time values into floats. I want to use ass-compiler for a subtitle editor and I'm using HTML time inputs which take in (and return) timecodes, so I need to parse these back and forth.

Would you consider adding a setting to disable time parsing? Or accept a PR for it?

weizhenye commented 3 months ago

Will it helpful if parseTime and stringifyTime is provided?

import { parseTime, stringifyTime } from 'ass-compiler';
TheJanusz commented 3 months ago

The provided methods for conversion definitely help. I guess I just wanted to learn why are they necessary in the first place?

EDIT: For my use caseit would be easier to work with timecodes directly.

weizhenye commented 3 months ago

ass-compiler is original separated from ASS.js, which is used for rendering ASS, parsing times into floats is the way to 'use' it.

Other use cases like sorting or converting to SRT, VTT subtitles are also requires floats.

Subtitle editor is surely a use case, but if take more things like validation into consideration, maybe raw string is harder to handle with.

The provided API call parse, keep it as raw string makes me feel it's not parsed.

TheJanusz commented 3 months ago

Thank you for the explanation! I suspected it was for compatibility with something. I will continue using the conversion methods then.

Feel free to close this issue. I appreciate you taking time to help.