diff --git a/enzyme/mkv.py b/enzyme/mkv.py index f90c043..9dbce9b 100644 --- a/enzyme/mkv.py +++ b/enzyme/mkv.py @@ -157,7 +157,7 @@ def fromelement(cls, element): type = element.get('TrackType') # @ReservedAssignment number = element.get('TrackNumber', 0) name = element.get('Name') - language = element.get('Language', 'eng') + language = element.get('Language') enabled = bool(element.get('FlagEnabled', 1)) default = bool(element.get('FlagDefault', 1)) forced = bool(element.get('FlagForced', 0)) @@ -201,7 +201,7 @@ def fromelement(cls, element): videotrack.width = element['Video'].get('PixelWidth', 0) videotrack.height = element['Video'].get('PixelHeight', 0) videotrack.interlaced = bool(element['Video'].get('FlagInterlaced', False)) - videotrack.stereo_mode = element['Video'].get('StereoMode', 0) + videotrack.stereo_mode = element['Video'].get('StereoMode') videotrack.crop = {} if 'PixelCropTop' in element['Video']: videotrack.crop['top'] = element['Video']['PixelCropTop'] @@ -211,10 +211,10 @@ def fromelement(cls, element): videotrack.crop['left'] = element['Video']['PixelCropLeft'] if 'PixelCropRight' in element['Video']: videotrack.crop['right'] = element['Video']['PixelCropRight'] - videotrack.display_unit = element['Video'].get('DisplayUnit') videotrack.display_width = element['Video'].get('DisplayWidth') videotrack.display_height = element['Video'].get('DisplayHeight') - videotrack.aspect_ratio_type = element['Video'].get('AspectRatioType', 0) + videotrack.display_unit = element['Video'].get('DisplayUnit') + videotrack.aspect_ratio_type = element['Video'].get('AspectRatioType') return videotrack def __repr__(self): @@ -245,7 +245,7 @@ def fromelement(cls, element): audiotrack = super(AudioTrack, cls).fromelement(element) audiotrack.sampling_frequency = element['Audio'].get('SamplingFrequency', 8000.0) audiotrack.channels = element['Audio'].get('Channels', 1) - audiotrack.output_sampling_frequency = element['Audio'].get('OutputSamplingFrequency', audiotrack.sampling_frequency) + audiotrack.output_sampling_frequency = element['Audio'].get('OutputSamplingFrequency') audiotrack.bit_depth = element['Audio'].get('BitDepth') return audiotrack diff --git a/enzyme/tests/test_mkv.py b/enzyme/tests/test_mkv.py index e97d760..2403661 100644 --- a/enzyme/tests/test_mkv.py +++ b/enzyme/tests/test_mkv.py @@ -44,12 +44,12 @@ def test_test1(self): self.assertTrue(mkv.video_tracks[0].width == 854) self.assertTrue(mkv.video_tracks[0].height == 480) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width is None) self.assertTrue(mkv.video_tracks[0].display_height is None) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio track self.assertTrue(len(mkv.audio_tracks) == 1) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) @@ -64,7 +64,7 @@ def test_test1(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) # subtitle track self.assertTrue(len(mkv.subtitle_tracks) == 0) @@ -113,12 +113,12 @@ def test_test2(self): self.assertTrue(mkv.video_tracks[0].width == 1024) self.assertTrue(mkv.video_tracks[0].height == 576) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width == 1354) self.assertTrue(mkv.video_tracks[0].display_height is None) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio track self.assertTrue(len(mkv.audio_tracks) == 1) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) @@ -133,7 +133,7 @@ def test_test2(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) # subtitle track self.assertTrue(len(mkv.subtitle_tracks) == 0) @@ -182,18 +182,18 @@ def test_test3(self): self.assertTrue(mkv.video_tracks[0].width == 1024) self.assertTrue(mkv.video_tracks[0].height == 576) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width is None) self.assertTrue(mkv.video_tracks[0].display_height is None) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio track self.assertTrue(len(mkv.audio_tracks) == 1) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) self.assertTrue(mkv.audio_tracks[0].number == 2) self.assertTrue(mkv.audio_tracks[0].name is None) - self.assertTrue(mkv.audio_tracks[0].language == 'eng') + self.assertTrue(mkv.audio_tracks[0].language is None) self.assertTrue(mkv.audio_tracks[0].enabled == True) self.assertTrue(mkv.audio_tracks[0].default == True) self.assertTrue(mkv.audio_tracks[0].forced == False) @@ -202,7 +202,7 @@ def test_test3(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) # subtitle track self.assertTrue(len(mkv.subtitle_tracks) == 0) @@ -251,12 +251,12 @@ def test_test5(self): self.assertTrue(mkv.video_tracks[0].width == 1024) self.assertTrue(mkv.video_tracks[0].height == 576) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width == 1024) self.assertTrue(mkv.video_tracks[0].display_height == 576) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio tracks self.assertTrue(len(mkv.audio_tracks) == 2) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) @@ -271,12 +271,12 @@ def test_test5(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) self.assertTrue(mkv.audio_tracks[1].type == AUDIO_TRACK) self.assertTrue(mkv.audio_tracks[1].number == 10) self.assertTrue(mkv.audio_tracks[1].name == 'Commentary') - self.assertTrue(mkv.audio_tracks[1].language == 'eng') + self.assertTrue(mkv.audio_tracks[1].language is None) self.assertTrue(mkv.audio_tracks[1].enabled == True) self.assertTrue(mkv.audio_tracks[1].default == False) self.assertTrue(mkv.audio_tracks[1].forced == False) @@ -292,7 +292,7 @@ def test_test5(self): self.assertTrue(mkv.subtitle_tracks[0].type == SUBTITLE_TRACK) self.assertTrue(mkv.subtitle_tracks[0].number == 3) self.assertTrue(mkv.subtitle_tracks[0].name is None) - self.assertTrue(mkv.subtitle_tracks[0].language == 'eng') + self.assertTrue(mkv.subtitle_tracks[0].language is None) self.assertTrue(mkv.subtitle_tracks[0].enabled == True) self.assertTrue(mkv.subtitle_tracks[0].default == True) self.assertTrue(mkv.subtitle_tracks[0].forced == False) @@ -414,12 +414,12 @@ def test_test6(self): self.assertTrue(mkv.video_tracks[0].width == 854) self.assertTrue(mkv.video_tracks[0].height == 480) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width is None) self.assertTrue(mkv.video_tracks[0].display_height is None) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio track self.assertTrue(len(mkv.audio_tracks) == 1) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) @@ -434,7 +434,7 @@ def test_test6(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) # subtitle track self.assertTrue(len(mkv.subtitle_tracks) == 0) @@ -483,12 +483,12 @@ def test_test7(self): self.assertTrue(mkv.video_tracks[0].width == 1024) self.assertTrue(mkv.video_tracks[0].height == 576) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width is None) self.assertTrue(mkv.video_tracks[0].display_height is None) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio track self.assertTrue(len(mkv.audio_tracks) == 1) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) @@ -503,7 +503,7 @@ def test_test7(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) # subtitle track self.assertTrue(len(mkv.subtitle_tracks) == 0) @@ -552,12 +552,12 @@ def test_test8(self): self.assertTrue(mkv.video_tracks[0].width == 1024) self.assertTrue(mkv.video_tracks[0].height == 576) self.assertTrue(mkv.video_tracks[0].interlaced == False) - self.assertTrue(mkv.video_tracks[0].stereo_mode == 0) + self.assertTrue(mkv.video_tracks[0].stereo_mode is None) self.assertTrue(mkv.video_tracks[0].crop == {}) self.assertTrue(mkv.video_tracks[0].display_width is None) self.assertTrue(mkv.video_tracks[0].display_height is None) self.assertTrue(mkv.video_tracks[0].display_unit is None) - self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0) + self.assertTrue(mkv.video_tracks[0].aspect_ratio_type is None) # audio track self.assertTrue(len(mkv.audio_tracks) == 1) self.assertTrue(mkv.audio_tracks[0].type == AUDIO_TRACK) @@ -572,7 +572,7 @@ def test_test8(self): self.assertTrue(mkv.audio_tracks[0].codec_name is None) self.assertTrue(mkv.audio_tracks[0].sampling_frequency == 48000.0) self.assertTrue(mkv.audio_tracks[0].channels == 2) - self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0) + self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency is None) self.assertTrue(mkv.audio_tracks[0].bit_depth is None) # subtitle track self.assertTrue(len(mkv.subtitle_tracks) == 0)