mirror of
https://github.com/iluvcapra/ptulsconv.git
synced 2025-12-31 08:50:48 +00:00
Added footage decode featue
This commit is contained in:
@@ -1,20 +1,18 @@
|
||||
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+)?')
|
||||
m = re.match(r'(\d+)\+(\d+)(\.\d+)?', footage)
|
||||
if m is None:
|
||||
return None
|
||||
|
||||
feet, frames = m.groups()
|
||||
feet, frames, _ = m.groups()
|
||||
feet, frames = int(feet), int(frames)
|
||||
|
||||
fps = 24
|
||||
frames_per_foot = 16
|
||||
|
||||
total_frames = feet * 16 + frames
|
||||
total_frames = feet * frames_per_foot + frames
|
||||
|
||||
return Fraction(total_frames, fps)
|
||||
return Fraction(total_frames, fps)
|
||||
|
||||
15
tests/unittests/test_footage.py
Normal file
15
tests/unittests/test_footage.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import unittest
|
||||
from ptulsconv import footage
|
||||
|
||||
class TestFootage(unittest.TestCase):
|
||||
def test_basic_footage(self):
|
||||
r1 = "90+0"
|
||||
f1 = footage.footage_to_seconds(r1)
|
||||
self.assertEqual(float(f1 or 0), 60.0)
|
||||
|
||||
def test_feet_and_frames(self):
|
||||
r1 = "1+8"
|
||||
f1 = footage.footage_to_seconds(r1)
|
||||
self.assertEqual(float(f1 or 0), 1.0)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user