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

Add realtime and systemtime getters. Preserve flags with operators. #52

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

cubicibo
Copy link

@cubicibo cubicibo commented Jan 12, 2024

The purpose of this MR is to add a mean to get the timestamps of a given SMPTE Timecode. Two timebases are considered:

  • Video system time: to_systemtime()
  • Real time: to_realtime()

NTSC framerates will return different values as the system time is not aligned to the wall-clock time. All others should return the exact same value.

DF 29.97:

> tc = Timecode("29.97", '00:59:59;29')
> tc.to_systemtime()
'01:00:00.000'
> tc.to_realtime()
'00:59:59.996'

NDF 29.97:

> tc = Timecode("29.97", '00:59:59:29', force_non_drop_frame=True)
> tc.to_systemtime()
'01:00:00.000'
> tc.to_realtime()
'01:00:03.600'

PAL 50:

> tc = Timecode("50", '00:59:59:49')
> tc.to_systemtime()
'01:00:00.000'
> tc.to_realtime()
'01:00:00.000'

I did not implement setters as I don't think there's a meaningful usage or need to them.
Hopefully this may help others understand better Timecodes running at different rates and the relations to the wall-clock time.

The second commit is to preserve the drop frame flag on elementary operations.

> tc = Timecode(29.97, '00:00:00:00',  force_non_drop_frame=True)
> assert tc.drop_frame is False
> tc = tc + 1
> tc
'00:00:00:01' #before: '00:00:00;01'
> tc.drop_frame
False #before: True

@cubicibo cubicibo changed the title Add realtime and systemtime getters. Add realtime and systemtime getters. Preserve flags with operators. Jan 17, 2024
@eoyilmaz
Copy link
Owner

Hey @cubicibo thank you for the PR, can you add tests related to what you have implemented.

@eoyilmaz eoyilmaz changed the base branch from master to develop January 17, 2024 15:33
@eoyilmaz eoyilmaz merged commit fa64212 into eoyilmaz:develop Jan 17, 2024
3 of 6 checks passed
@cubicibo cubicibo deleted the MR/timegets branch January 17, 2024 15:46
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