mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
20 lines
447 B
Python
20 lines
447 B
Python
from fractions import Fraction
|
|
import re
|
|
import math
|
|
from collections import namedtuple
|
|
from typing import Optional
|
|
|
|
def footage_to_seconds(footage: str) -> Optional[Fraction]:
|
|
m = re.match(r'(\d+)\+(\d+)(\.\d+)?')
|
|
if m is None:
|
|
return None
|
|
|
|
feet, frames = m.groups()
|
|
feet, frames = int(feet), int(frames)
|
|
|
|
fps = 24
|
|
frames_per_foot = 16
|
|
|
|
total_frames = feet * 16 + frames
|
|
|
|
return Fraction(total_frames, fps) |