Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timestamps without milliseconds #8

Open
jcable opened this issue Jun 3, 2023 · 0 comments
Open

timestamps without milliseconds #8

jcable opened this issue Jun 3, 2023 · 0 comments

Comments

@jcable
Copy link

jcable commented Jun 3, 2023

Hi, I found an EBU-TT-D file where some timestamps are without milliseconds. I made this small change to accommodate this:

def fraction_timestamp_to_ms(self, timestamp):
    """Convert hh:mm:ss.fraction to milliseconds
    """
    if '.' in timestamp:
      hh, mm, ss, fraction = re.split(r'[:.]', timestamp)
    else:
      hh, mm, ss = re.split(r'[:]', timestamp)
      fraction = '0'
    hh, mm, ss = [int(i) for i in (hh, mm, ss)]
    # Resolution beyond ms is useless for our purposes
    ms = int(fraction[:3])
    
    return self._scaler(self._hhmmss_to_ms(hh, mm, ss) + ms)
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

No branches or pull requests

1 participant