Skip to content

Commit

Permalink
Added workaround for properties with 0/0 values
Browse files Browse the repository at this point in the history
Storyboard Pro exports AAF in a weird way that can contain animated properties with 0/0 values, which is mathematically impossible. This is a workaround that falls back to a 0/1 value, which will be represented as 0.0 in the data.

Signed-off-by: Tim Lehr <[email protected]>
  • Loading branch information
timlehr authored and markreidvfx committed Aug 31, 2023
1 parent 23b6143 commit 5199279
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/aaf2/rational.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
)

import sys
import logging
from fractions import Fraction, _RATIONAL_FORMAT
from decimal import Decimal
import numbers
Expand Down Expand Up @@ -92,6 +93,16 @@ def __new__(cls, numerator=0, denominator=None):
"Rational instances")

if denominator == 0:
if numerator == 0:
# AAF seemingly can have valid 0/0 property values,
# which we default to 0/1, which is mathematically not
# correct but works around this weird AAF behaviour (observed in
# AAF files exported from Storyboard Pro)
logging.warning("Fraction(0,0) not mathematically plausible, "
"use Fraction(0,1) instead.")
self._numerator = 0
self._denominator = 1
return self
raise ZeroDivisionError('Fraction(%s, 0)' % numerator)
# don't find the gcd
#g = gcd(numerator, denominator)
Expand Down

0 comments on commit 5199279

Please sign in to comment.