FRMT implementation

This commit is contained in:
2025-12-16 12:37:16 -08:00
parent 23499b140c
commit 229f6d646b
4 changed files with 33 additions and 6 deletions

View File

@@ -1,7 +1,7 @@
# pycmx # pycmx
# (c) 2018 Jamie Hardt # (c) 2018 Jamie Hardt
from pycmx.statements import StmtCdlSat, StmtCdlSop from pycmx.statements import StmtCdlSat, StmtCdlSop, StmtFrmc
from .transition import Transition from .transition import Transition
from .channel_map import ChannelMap from .channel_map import ChannelMap
@@ -26,7 +26,7 @@ class Edit:
self.trans_name_statement = trans_name_statement self.trans_name_statement = trans_name_statement
self.asc_sop_statement: Optional[StmtCdlSop] = asc_sop_statement self.asc_sop_statement: Optional[StmtCdlSop] = asc_sop_statement
self.asc_sat_statement: Optional[StmtCdlSat] = asc_sat_statement self.asc_sat_statement: Optional[StmtCdlSat] = asc_sat_statement
self.frmc_statement = frmc_statement self.frmc_statement: Optional[StmtFrmc] = frmc_statement
@property @property
def line_number(self) -> int: def line_number(self) -> int:
@@ -150,3 +150,10 @@ class Edit:
Get ASC CDL saturation value for clip, if present Get ASC CDL saturation value for clip, if present
""" """
return self.asc_sat_statement return self.asc_sat_statement
@property
def frmc(self) -> Optional[StmtFrmc]:
"""
Get FRMC data
"""
return self.frmc_statement

View File

@@ -1,6 +1,7 @@
# pycmx # pycmx
# (c) 2023 Jamie Hardt # (c) 2023 Jamie Hardt
from pycmx.statements import StmtFrmc
from .parse_cmx_statements import ( from .parse_cmx_statements import (
StmtEvent, StmtClipName, StmtSourceFile, StmtAudioExt, StmtUnrecognized, StmtEvent, StmtClipName, StmtSourceFile, StmtAudioExt, StmtUnrecognized,
StmtEffectsName, StmtCdlSop, StmtCdlSat) StmtEffectsName, StmtCdlSop, StmtCdlSat)
@@ -76,7 +77,8 @@ class Event:
source_file_statement=s1, source_file_statement=s1,
trans_name_statement=u1, trans_name_statement=u1,
asc_sop_statement=self._asc_sop_statement(), asc_sop_statement=self._asc_sop_statement(),
asc_sat_statement=self._asc_sat_statement()) asc_sat_statement=self._asc_sat_statement(),
frmc_statement=self._frmc_statement())
for (e1, n1, s1, u1) in zip(*the_zip)] for (e1, n1, s1, u1) in zip(*the_zip)]
@property @property
@@ -116,3 +118,6 @@ class Event:
def _asc_sat_statement(self) -> Optional[StmtCdlSat]: def _asc_sat_statement(self) -> Optional[StmtCdlSat]:
return next((s for s in self.statements if type(s) is StmtCdlSat), return next((s for s in self.statements if type(s) is StmtCdlSat),
None) None)
def _frmc_statement(self) -> Optional[StmtFrmc]:
return next((s for s in self.statements if type(s) is StmtFrmc), None)

View File

@@ -136,8 +136,7 @@ def _parse_remark(line, line_number) -> object:
elif line.startswith("FRMC"): elif line.startswith("FRMC"):
match = re.match( match = re.match(
r'^FRMC START:\s*(\d+)\s+FRMC END:\s*(\d+)' r'^FRMC START:\s*(\d+)\s+FRMC END:\s*(\d+)'
r'\s+FRMC DURATION:\s*(\d+)', r'\s+FRMC DURATION:\s*(\d+)', line, re.IGNORECASE)
line)
if match is None: if match is None:
return StmtRemark(line, line_number) return StmtRemark(line, line_number)

View File

@@ -159,4 +159,20 @@ class TestParse(TestCase):
edl = pycmx.parse_cmx3600(f) edl = pycmx.parse_cmx3600(f)
for event in edl.events: for event in edl.events:
if event.number == 1: if event.number == 1:
... frmc = event.edits[0].frmc_statement
self.assertIsNotNone(frmc)
assert frmc
self.assertEqual(frmc.start, "1001")
self.assertEqual(frmc.end, "1102")
self.assertEqual(frmc.duration, "102")
with open("tests/edls/cdl_frmc_example02.edl", "r") as f:
edl = pycmx.parse_cmx3600(f)
for event in edl.events:
if event.number == 6:
frmc = event.edits[0].frmc_statement
self.assertIsNotNone(frmc)
assert frmc
self.assertEqual(frmc.start, "1001")
self.assertEqual(frmc.end, "1486")
self.assertEqual(frmc.duration, "486")