From 42d4e799d0fa3cc63f9b6ca728078619367f718d Mon Sep 17 00:00:00 2001 From: jiangying Date: Sun, 21 Jul 2024 00:26:19 +0800 Subject: [PATCH] Update utils.py --- pydub/utils.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/pydub/utils.py b/pydub/utils.py index 2694f90a..6ac64816 100644 --- a/pydub/utils.py +++ b/pydub/utils.py @@ -303,27 +303,26 @@ def set_property(stream, prop, value): stream[prop] = value for token in extra_info[stream['index']]: - m = re.match(r'([su]([0-9]{1,2})p?) \(([0-9]{1,2}) bit\)$', token) - m2 = re.match(r'([su]([0-9]{1,2})p?)( \(default\))?$', token) + m = re.match(r'([su]([0-9]{1,2})p?) (([0-9]{1,2}) bit)$', token) + m2 = re.match(r'([su]([0-9]{1,2})p?)( (default))?$', token) if m: set_property(stream, 'sample_fmt', m.group(1)) set_property(stream, 'bits_per_sample', int(m.group(2))) - set_property(stream, 'bits_per_raw_sample', int(m.group(3))) + set_property(stream, 'bits_per_raw_sample', int(m.group(4))) elif m2: set_property(stream, 'sample_fmt', m2.group(1)) set_property(stream, 'bits_per_sample', int(m2.group(2))) set_property(stream, 'bits_per_raw_sample', int(m2.group(2))) - elif re.match(r'(flt)p?( \(default\))?$', token): + elif re.match(r'(flt)p?( (default))?$', token): set_property(stream, 'sample_fmt', token) set_property(stream, 'bits_per_sample', 32) set_property(stream, 'bits_per_raw_sample', 32) - elif re.match(r'(dbl)p?( \(default\))?$', token): + elif re.match(r'(dbl)p?( (default))?$', token): set_property(stream, 'sample_fmt', token) set_property(stream, 'bits_per_sample', 64) set_property(stream, 'bits_per_raw_sample', 64) return info - def mediainfo(filepath): """Return dictionary with media info(codec, duration, size, bitrate...) from filepath """