Last active
July 12, 2020 02:58
-
-
Save OrangeChannel/330a032e4d6cf9265b8b007c41112937 to your computer and use it in GitHub Desktop.
Useful for creating chapter files based on 0-indexed frame numbers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Chapter timings generator | |
""" | |
import math | |
from fractions import Fraction | |
frame_no = input('Frame number(s) (\'34 7004 13451\'): ') | |
frames = list(map(int, frame_no.split())) | |
fps = input('FPS (n/d) (blank for 23.976): ') | |
if fps is not '': | |
n, d = fps.split('/') | |
n = int(n) | |
d = int(d) | |
else: | |
n = 24000 | |
d = 1001 | |
for v in frames: | |
t = round(10 ** 9 * v * Fraction(d, n)) | |
s = t / 10 ** 9 | |
m = s // 60 | |
s = s % 60 | |
h = m // 60 | |
m = m % 60 | |
print('{:02.0f}:{:02.0f}:{:012.9f}'.format(h, m, s)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment