Skip to content

Commit

Permalink
Ignore invalid drop-frame if not NTSC framerate
Browse files Browse the repository at this point in the history
  • Loading branch information
mivk committed Jul 9, 2020
1 parent 149a935 commit 6404144
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions SMPTE.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ def __init__(self, *args):
self.fps = args[0] if len(args) > 0 else 24
self.df = args[1] if len(args) > 1 else False

def df_check(self):
if self.df and ( self.fps == int(self.fps) or int(self.fps) not in (29, 59) ):
import sys
sys.stderr.write('Ignoring invalid drop-frame option with ' + str(self.fps) + " fps!\n")
return False

def getframes(self, tc):
'''Converts SMPTE timecode to frame count.'''
Expand All @@ -31,7 +36,7 @@ def getframes(self, tc):
frm = int((min*60 + sec) * self.fps + int(tc[9:]))

# Drop frame adjustment
if self.df:
if self.df and self.df_check():
# Subtract 2 frames for each minute...
dffrm = frm - min * 2
# ...except every 10 minutes.
Expand All @@ -52,7 +57,7 @@ def gettc(self, frames):
spacer = spacer2 = ':'

# Drop frame adjustment
if self.df:
if self.df and self.df_check():
spacer2 = ';'
minfactor = self.fps * 60
tenminfactor = self.fps * 600
Expand Down

0 comments on commit 6404144

Please sign in to comment.