'python-enzyme KeyError when accessing MKV video file

I'm writing a script to convert mkv files en masse, and when I try accessing the files' metadata (done in a loop), all of them throw a KeyError except for one file, which works as expected.

Code inside of the loop:

try:  # Attempting to procure metadata from file
                with open(filename, 'rb') as f:
                    mkv = enzyme.MKV(f)
                    print(f'{mkv.info}\n{mkv.video_tracks}\n{mkv.audio_tracks}')
            except KeyError as e:
                print(f'Unable to procure metadata for {filename}. Error: {KeyError}, {e}')
            except Exception as e:
                print(f'Error: {Exception}, {e}')

Expected output (the one file that works):

조광조 4회.mkv {'title': None, 'duration': datetime.timedelta(seconds=3122, microseconds=621000), 'date_utc': None, 'muxing_app': 'Lavf58.20.100', 'writing_app': 'Lavf58.20.100'}
[<VideoTrack [1, 720x480, V_VP9, name=None, language=und]>]
[<AudioTrack [2, 2 channel(s), 48000Hz, A_OPUS, name=None, language=und]>]

The files that don't:

조광조 50회.mkv Unable to procure metadata for 조광조 50회.mkv. Error: <class 'KeyError'>, 26281

(I used a catch for this, traceback is as follows):

Traceback (most recent call last):
  File "/home/nicolas/PycharmProjects/Avidemux/main.py", line 38, in <module>
    convert_file(dir_name, format_name)
  File "/home/nicolas/PycharmProjects/Avidemux/main.py", line 20, in convert_file
    mkv = enzyme.MKV(f)
  File "/usr/lib/python3/dist-packages/enzyme/mkv.py", line 54, in __init__
    self._parse_seekhead(seek_head, segment, stream, specs)
  File "/usr/lib/python3/dist-packages/enzyme/mkv.py", line 61, in _parse_seekhead
    element_name = specs[element_id][1]
KeyError: 26281


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source