Skip to content

Commit

Permalink
mp4: include codec information in ~format instead of defaulting to AA…
Browse files Browse the repository at this point in the history
…C. Closes issue #1505.
  • Loading branch information
lazka committed Feb 4, 2015
1 parent a96521a commit 4033cff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion quodlibet/quodlibet/formats/mp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@


class MP4File(AudioFile):
format = "MPEG-4 AAC"
format = "MPEG-4"
mimes = ["audio/mp4", "audio/x-m4a", "audio/mpeg4", "audio/aac"]

__translate = {
Expand Down Expand Up @@ -60,6 +60,8 @@ class MP4File(AudioFile):

def __init__(self, filename):
audio = MP4(filename)
self["~format"] = "%s %s" % (
self.format, getattr(audio.info, "codec_description", "AAC"))
self["~#length"] = int(audio.info.length)
self["~#bitrate"] = int(audio.info.bitrate / 1000)
for key, values in audio.items():
Expand Down
7 changes: 7 additions & 0 deletions quodlibet/tests/test_formats_mp4.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import os
import shutil
import StringIO
import mutagen

from tests import TestCase, DATA_DIR, mkstemp
from quodlibet.formats.mp4 import MP4File
Expand All @@ -27,6 +28,12 @@ def setUp(self):
def tearDown(self):
os.unlink(self.f)

def test_format(self):
if mutagen.version >= (1, 27):
self.assertEqual(self.song("~format"), "MPEG-4 AAC LC")
else:
self.assertEqual(self.song("~format"), "MPEG-4 AAC")

def test_basic(self):
self.song["title"] = u"SomeTestValue"
self.song.write()
Expand Down

0 comments on commit 4033cff

Please sign in to comment.