Skip to content

Commit

Permalink
Disable LegacyStreamDisplay explicitly by default, make it configurable
Browse files Browse the repository at this point in the history
This is done to match the change in the library in:
MediaArea/MediaInfoLib@090e147
and therefore included since MediaInfo v18.08.

The older behaviour can still be reproduced by setting
legacy_stream_display=True.
  • Loading branch information
sbraz committed Apr 4, 2019
1 parent 58d99a5 commit 9aa65d8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pymediainfo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def can_parse(cls, library_file=None):
@classmethod
def parse(cls, filename, library_file=None, cover_data=False,
encoding_errors="strict", parse_speed=0.5, text=False,
full=True):
full=True, legacy_stream_display=False):
"""
Analyze a media file using libmediainfo.
If libmediainfo is located in a non-standard location, the `library_file` parameter can be used:
Expand All @@ -242,6 +242,7 @@ def parse(cls, filename, library_file=None, cover_data=False,
of a :class:`MediaInfo` object.
:param bool full: display additional tags, including computer-readable values
for sizes and durations.
:param bool legacy_stream_display: display additional information about streams.
:type filename: str or pathlib.Path
:rtype: str if `text` is ``True``.
:rtype: :class:`MediaInfo` otherwise.
Expand Down Expand Up @@ -288,6 +289,7 @@ def parse(cls, filename, library_file=None, cover_data=False,
lib.MediaInfo_Option(None, "Inform", "" if text else xml_option)
lib.MediaInfo_Option(None, "Complete", "1" if full else "")
lib.MediaInfo_Option(None, "ParseSpeed", str(parse_speed))
lib.MediaInfo_Option(None, "LegacyStreamDisplay", "1" if legacy_stream_display else "")
if lib.MediaInfo_Open(handle, filename) == 0:
raise RuntimeError("An eror occured while opening {}"
" with libmediainfo".format(filename))
Expand Down
Binary file added tests/data/aac_he_v2.aac
Binary file not shown.
8 changes: 8 additions & 0 deletions tests/test_pymediainfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,11 @@ def setUp(self):
self.mi = MediaInfo.parse(os.path.join(data_dir, "sample.mp4"), text=True)
def test_text_output(self):
self.assertRegex(self.mi, r"Stream size\s+: 373836\b")

class MediaInfoLegacyStreamDisplayTest(unittest.TestCase):
def setUp(self):
self.mi = MediaInfo.parse(os.path.join(data_dir, "aac_he_v2.aac"))
self.legacy_mi = MediaInfo.parse(os.path.join(data_dir, "aac_he_v2.aac"), legacy_stream_display=True)
def test_legacy_stream_display(self):
self.assertEqual(self.mi.tracks[1].channel_s, 2)
self.assertEqual(self.legacy_mi.tracks[1].channel_s, "2 / 1 / 1")

0 comments on commit 9aa65d8

Please sign in to comment.