Skip to content

Track index out of range Error When Initial MKVTrack #46

@Masterain98

Description

@Masterain98

Describe the bug

When adapting pymkv2 from pymkv library, I notice that when initialing an MKVTrack from an existing file, an IndexError: track index out of range error will occur.

To Reproduce

My source code:
https://github.com/Masterain98/PlexMuxy/blob/a0e9c9fab409667a3daaf7f3a34ad7befaa1b617/main.py#L107-L115


Minimum reproduce:

    mkv = pymkv.MKVFile("./sample.mkv", mkvmerge_path=MKVMerge)
    mkv.add_track(pymkv.MKVTrack("./sample.JPSC.ass", mkvmerge_path=MKVMerge))

Expected behavior

MKVTrack can be created, separated, and added to MKVFile. This can be achieved in the old pymkv library without any error.

Screenshots

Traceback (most recent call last):
  File "C:\Users\i\Documents\GitHub\pymkv2\simple_tests\simple_test.py", line 11, in <module>
    process_file()
  File "C:\Users\i\Documents\GitHub\pymkv2\simple_tests\simple_test.py", line 8, in process_file
    mkv.add_track(pymkv.MKVTrack("./sample.JPSC.ass", mkvmerge_path=MKVMerge))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\i\Documents\GitHub\pymkv2\pymkv\MKVTrack.py", line 145, in __init__
    self.file_path = file_path
    ^^^^^^^^^^^^^^
  File "C:\Users\i\Documents\GitHub\pymkv2\pymkv\MKVTrack.py", line 218, in file_path
    self.track_id = 0
    ^^^^^^^^^^^^^
  File "C:\Users\i\Documents\GitHub\pymkv2\pymkv\utils.py", line 98, in wrapper
    return method(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\i\Documents\GitHub\pymkv2\pymkv\MKVTrack.py", line 289, in track_id
    raise IndexError(msg)
IndexError: track index out of range

Software (please complete the following information):

  • OS: Windows 10 22H2
  • MKVToolNix v88

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions