Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Timecode.frames in mtc_decode #6

Open
Tomasz-Mankowski opened this issue Mar 26, 2022 · 0 comments
Open

TypeError: Timecode.frames in mtc_decode #6

Tomasz-Mankowski opened this issue Mar 26, 2022 · 0 comments

Comments

@Tomasz-Mankowski
Copy link

Environment:

  • Windows 10
  • python 3.9.10
  • mido 1.2.10
  • python-rtmidi 1.4.9
  • timecode 1.3.1

Input: 24 fps quarter frame

While running mtc_listener.py call of mtc_decode rises error:

  File "***\timecode_tools\mtc_listener.py", line 46, in <module>
    main()
  File "***\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "***\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "***\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "***\AppData\Local\Programs\Python\Python39\lib\site-packages\click\core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "***\timecode_tools\mtc_listener.py", line 43, in main
    listen(port)
  File "***\timecode_tools\mtc_listener.py", line 33, in listen
    handle_message(msg)
  File "***\timecode_tools\mtc_listener.py", line 15, in handle_message
    tc = tools.mtc_decode_quarter_frames(quarter_frames)
  File "***\timecode_tools\tools.py", line 208, in mtc_decode_quarter_frames
    return mtc_decode(mtc_bytes)
  File ***\timecode_tools\tools.py", line 158, in mtc_decode
    return Timecode(fps, frames=total_frames)
  File "***\Local\Programs\Python\Python39\lib\site-packages\timecode\__init__.py", line 80, in __init__
    self.frames = frames
  File "***\AppData\Local\Programs\Python\Python39\lib\site-packages\timecode\__init__.py", line 105, in frames
    raise TypeError(
TypeError: Timecode.frames should be a positive integer bigger than zero, not a float

Indeed total_frames is a float value, and frames value is forced to be int:

    @frames.setter
    def frames(self, frames):
        """setter for the _frames attribute

        :param int frames: A positive int bigger than zero showing the number
          of frames that this TimeCode represents.
        :return:
        """
        # validate the frames value
        if not isinstance(frames, int):
            raise TypeError(
                "%s.frames should be a positive integer bigger "
                "than zero, not a %s" % (self.__class__.__name__, frames.__class__.__name__)
            )

Changing return Timecode(fps, frames=total_frames) to return Timecode(fps, frames=int(total_frames)) fixes this issue.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant