Permalink
Browse files

Additional fixes to support m4a files encoded with Fraunhofer AAC

  • Loading branch information...
1 parent d0c36c1 commit 6fc8d8faa3328a910b254b18d9f0cf4af9b6f92b @Happy-Neko Happy-Neko committed Apr 27, 2013
Showing with 29 additions and 3 deletions.
  1. +29 −3 src/main/java/net/pms/dlna/LibMediaInfoParser.java
@@ -2,16 +2,16 @@
import net.pms.configuration.FormatConfiguration;
import net.pms.formats.v2.SubtitleType;
-
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.lang3.StringUtils;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.StringTokenizer;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+
public class LibMediaInfoParser {
private static final Logger LOGGER = LoggerFactory.getLogger(LibMediaInfoParser.class);
private static MediaInfo MI;
@@ -210,6 +210,32 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
addSub(currentSubTrack, media);
}
+ /*
+ Native M4A/AAC streaming bug: http://www.ps3mediaserver.org/forum/viewtopic.php?f=6&t=16691
+ Some M4A files have generic codec id "mp42" instead of "M4A". For example:
+
+ General
+ Format : MPEG-4
+ Format profile : Apple audio with iTunes info
+ Codec ID : M4A
+
+ vs
+
+ General
+ Format : MPEG-4
+ Format profile : Base Media / Version 2
+ Codec ID : mp42
+
+ As workaround set container type to AAC for MP4 files with single AAC audio track and no video.
+ */
+ if (FormatConfiguration.MP4.equals(media.getContainer())
+ && isBlank(media.getCodecV())
+ && media.getAudioTracksList() != null
+ && media.getAudioTracksList().size() == 1
+ && FormatConfiguration.AAC.equals(media.getAudioTracksList().get(0).getCodecA())) {
+ media.setContainer(FormatConfiguration.AAC);
+ }
+
media.finalize(type, inputFile);
} catch (Exception e) {
LOGGER.error("Error in MediaInfo parsing:", e);
@@ -327,7 +353,7 @@ private static void getFormat(MediaInfo.StreamKind streamType, DLNAMediaInfo med
format = FormatConfiguration.TRUEHD;
} else if (value.equals("55") || value.equals("a_mpeg/l3")) {
format = FormatConfiguration.MP3;
- } else if (value.equals("m4a") || value.equals("40") || value.equals("a_aac") || value.equals("aac") || value.equals("mp42")) {
+ } else if (value.equals("m4a") || value.equals("40") || value.equals("a_aac") || value.equals("aac")) {
format = FormatConfiguration.AAC;
} else if (value.equals("pcm") || (value.equals("1") && (audio.getCodecA() == null || !audio.getCodecA().equals(FormatConfiguration.DTS)))) {
format = FormatConfiguration.LPCM;

0 comments on commit 6fc8d8f

Please sign in to comment.