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

Fix defaults #30

Merged
merged 3 commits into from
Jun 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions enzyme/mkv.py
Original file line number Diff line number Diff line change
@@ -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')
language = element.get('Language', 'eng')
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')
videotrack.stereo_mode = element['Video'].get('StereoMode', 0)
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.display_unit = element['Video'].get('DisplayUnit')
videotrack.aspect_ratio_type = element['Video'].get('AspectRatioType')
videotrack.aspect_ratio_type = element['Video'].get('AspectRatioType', 0)
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.output_sampling_frequency = element['Audio'].get('OutputSamplingFrequency', audiotrack.sampling_frequency)
audiotrack.bit_depth = element['Audio'].get('BitDepth')
return audiotrack

48 changes: 24 additions & 24 deletions enzyme/tests/test_mkv.py
Original file line number Diff line number Diff line change
@@ -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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].language == 'eng')
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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
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 is None)
self.assertTrue(mkv.audio_tracks[1].language == 'eng')
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 is None)
self.assertTrue(mkv.subtitle_tracks[0].language == 'eng')
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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
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 is None)
self.assertTrue(mkv.video_tracks[0].stereo_mode == 0)
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 is None)
self.assertTrue(mkv.video_tracks[0].aspect_ratio_type == 0)
# 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 is None)
self.assertTrue(mkv.audio_tracks[0].output_sampling_frequency == 48000.0)
self.assertTrue(mkv.audio_tracks[0].bit_depth is None)
# subtitle track
self.assertTrue(len(mkv.subtitle_tracks) == 0)