Skip to content

Conversation

@ALRBP
Copy link

@ALRBP ALRBP commented Sep 28, 2025

Fixes #443

"bad lexical cast" when parsing .ass file.

When the parser fails to parse an integer, it will now try to parse and round a float, if this also fails (eg. empty value) it defaults to 0.

@arch1t3cht
Copy link
Member

While this PR improves parsing in some places, it's not complete. The main two issues are:

  • It updates parsing for margins in dialogue lines but does not update the parsing of any other int values (dialogue layer numbers and various style fields)
  • It does not fully match vsfilter/libass's parsing. For example, it does not recognize &H hexadecimals, and it incorrectly parses decimal numbers as floats with some rounding logic that will likely break in edge cases.

If integer parsing is updated, I'd like to make it fully match vsfilter/libass's parsing across all integer values. In fact, I think the best course of action is to just copy-paste the relevant libass code with a comment explaining the motivation and giving the proper copyright notices.

(In theory it's also possible to call libass directly to do the parsing, but that would need a fair bit of hacking to handle cases like comments, invalid styles, etc.)

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.

Fail to parse .ass file when some margin is not an integer

2 participants