Skip to content
Open
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/main/external-resources/renderers/DefaultRenderer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -690,10 +690,11 @@ CharMap =
# ------------------------------------
# ASS .ass or .ssa
# MICRODVD .sub
# PGS .sup or .pgs
# SAMI .smi
# SUBRIP .srt
# TEXT .txt
# WEBVTT .wtt
# WEBVTT .vtt
#
# Example: SupportedExternalSubtitlesFormats = SUBRIP,ASS,MICRODVD
# Default: ""
Expand All @@ -716,7 +717,9 @@ VideoFormatsSupportingStreamedExternalSubtitles =
# ------------------------------------
# ASS .ass/.ssa
# BMP
# EIA608
# DIVX (XSUB)
# DVBSUB
# MICRODVD .sub
# PGS .sup
# SAMI .smi
Expand Down
4 changes: 2 additions & 2 deletions src/main/external-resources/renderers/Kodi.conf
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,5 @@ Supported = f:wavpack m:audio/x-wavpack
Supported = f:wma m:audio/x-ms-wma

# Supported subtitles formats:
SupportedExternalSubtitlesFormats = ASS,MICRODVD,PGS,SAMI,SUBRIP,TEXT,UFS,VOBSUB,WEBVTT
SupportedInternalSubtitlesFormats = ASS,MICRODVD,PGS,SAMI,SUBRIP,TEXT,UFS,VOBSUB,WEBVTT
SupportedExternalSubtitlesFormats = ASS,MICRODVD,PGS,SAMI,SUBRIP,TEXT,VOBSUB,WEBVTT
SupportedInternalSubtitlesFormats = ASS,DVBSUB,EIA608,EIA708,MICRODVD,PGS,SAMI,SUBRIP,TEXT,TX3G,USF,VOBSUB
2 changes: 1 addition & 1 deletion src/main/external-resources/renderers/VLC-for-desktop.conf
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ Supported = f:dts m:audio/vnd.dts
Supported = f:flac m:audio/flac
Supported = f:oga m:audio/ogg

SupportedInternalSubtitlesFormats = ASS,SUBRIP
SupportedInternalSubtitlesFormats = ASS,DVBSUB,EIA608,EIA708,KATE,PGS,SUBRIP,TELETEXT,TX3G,USF,VOBSUB
12 changes: 12 additions & 0 deletions src/main/java/net/pms/dlna/DLNAMediaInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -1358,8 +1358,20 @@ public void parseFFmpegInfo(List<String> lines, String input) {
lang.setType(SubtitleType.DIVX);
} else if (line.contains("mov_text")) {
lang.setType(SubtitleType.TX3G);
} else if (line.contains("ttml")) {
lang.setType(SubtitleType.TTML);
} else if (line.contains("webvtt")) {
lang.setType(SubtitleType.WEBVTT);
} else if (line.contains("dvb_subtitle")) {
lang.setType(SubtitleType.DVBSUB);
} else if (line.contains("hdmv_pgs_subtitle")) {
lang.setType(SubtitleType.PGS);
} else if (line.contains("eia_608")) {
lang.setType(SubtitleType.EIA608);
} else if (line.contains("eia_708")) {
lang.setType(SubtitleType.EIA708);
} else if (line.contains("dvb_teletext")) {
lang.setType(SubtitleType.TELETEXT);
} else {
lang.setType(SubtitleType.UNKNOWN);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/pms/dlna/DLNAMediaSubtitle.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public String toString() {
result.append("id: ");
result.append(getId());
result.append(", type: ");
result.append(type);
result.append(getType());

if (isNotBlank(subtitlesTrackTitleFromMetadata)) {
result.append(", subtitles track title from metadata: ");
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/net/pms/dlna/DLNAResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -1659,8 +1659,9 @@ private String getDisplayName(RendererConfiguration mediaRenderer, boolean withS

String audioTrackTitle = "";
if (
getMediaAudio().getAudioTrackTitleFromMetadata() != null &&
!"".equals(getMediaAudio().getAudioTrackTitleFromMetadata()) &&
StringUtils.isNotBlank(getMediaAudio().getAudioTrackTitleFromMetadata()) &&
getFormat() != null &&
!getFormat().isVideo() &&
mediaRenderer != null &&
mediaRenderer.isShowAudioMetadata()
) {
Expand All @@ -1677,11 +1678,6 @@ private String getDisplayName(RendererConfiguration mediaRenderer, boolean withS
!configurationSpecificToRenderer.hideSubsInfo()
) {
subtitleFormat = media_subtitle.getType().getDescription();
if ("(Advanced) SubStation Alpha".equals(subtitleFormat)) {
subtitleFormat = "SSA";
} else if ("Blu-ray subtitles".equals(subtitleFormat)) {
subtitleFormat = "PGS";
}

subtitleLanguage = "/" + media_subtitle.getLangFullName();
if ("/Undetermined".equals(subtitleLanguage)) {
Expand Down
89 changes: 57 additions & 32 deletions src/main/java/net/pms/dlna/LibMediaInfoParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
StreamType audio = StreamType.Audio;
StreamType image = StreamType.Image;
StreamType text = StreamType.Text;
StreamType other = StreamType.Other;
DLNAMediaAudio currentAudioTrack = new DLNAMediaAudio();
DLNAMediaSubtitle currentSubTrack;
media.setSize(file.length());
Expand All @@ -90,7 +91,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
media.setBitrate(getBitrate(MI.Get(general, 0, "OverallBitRate")));
media.setStereoscopy(MI.Get(general, 0, "StereoscopicLayout"));
value = MI.Get(general, 0, "Cover_Data");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
try {
media.setThumb(DLNAThumbnail.toThumbnail(
new Base64().decode(value.getBytes(StandardCharsets.US_ASCII)),
Expand All @@ -114,7 +115,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
}

value = MI.Get(general, 0, "Title");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
media.setFileTitleFromMetadata(value);
}

Expand Down Expand Up @@ -151,17 +152,17 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
media.setReferenceFrameCount(getReferenceFrameCount(MI.Get(video, i, "Format_Settings_RefFrames/String")));
media.setVideoTrackTitleFromMetadata(MI.Get(video, i, "Title"));
value = MI.Get(video, i, "Format_Settings_QPel");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
media.putExtra(FormatConfiguration.MI_QPEL, value);
}

value = MI.Get(video, i, "Format_Settings_GMC");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
media.putExtra(FormatConfiguration.MI_GMC, value);
}

value = MI.Get(video, i, "Format_Settings_GOP");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
media.putExtra(FormatConfiguration.MI_GOP, value);
}

Expand All @@ -171,7 +172,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
}

value = MI.Get(video, i, "BitDepth");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
try {
media.setVideoBitDepth(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
Expand All @@ -181,7 +182,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
}

value = MI.Get(video, i, "Format_Profile");
if (!value.isEmpty() && media.getCodecV() != null && media.getCodecV().equals(FormatConfiguration.H264)) {
if (isNotBlank(value) && media.getCodecV() != null && media.getCodecV().equals(FormatConfiguration.H264)) {
media.setAvcLevel(getAvcLevel(value));
}
}
Expand All @@ -200,7 +201,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
if (isNotBlank(value) && value.startsWith("Windows Media Audio 10")) {
currentAudioTrack.setCodecA(FormatConfiguration.WMA10);
}
currentAudioTrack.setLang(getLang(MI.Get(audio, i, "Language/String")));
currentAudioTrack.setLang(getLang(MI.Get(audio, i, "Language")));
currentAudioTrack.setAudioTrackTitleFromMetadata((MI.Get(audio, i, "Title")).trim());
currentAudioTrack.getAudioProperties().setNumberOfChannels(MI.Get(audio, i, "Channel(s)"));
currentAudioTrack.setSampleFrequency(getSampleFrequency(MI.Get(audio, i, "SamplingRate")));
Expand Down Expand Up @@ -231,17 +232,17 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
}

// Special check for OGM: MediaInfo reports specific Audio/Subs IDs (0xn) while mencoder does not
value = MI.Get(audio, i, "ID/String");
if (!value.isEmpty()) {
if (value.contains("(0x") && !FormatConfiguration.OGG.equals(media.getContainer())) {
value = MI.Get(audio, i, "ID");
if (isNotBlank(value)) {
if (!FormatConfiguration.OGG.equals(media.getContainer())) {
currentAudioTrack.setId(getSpecificID(value));
} else {
currentAudioTrack.setId(media.getAudioTracksList().size());
}
}

value = MI.Get(general, i, "Track/Position");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
try {
currentAudioTrack.setTrack(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
Expand All @@ -250,7 +251,7 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
}

value = MI.Get(audio, i, "BitDepth");
if (!value.isEmpty()) {
if (isNotBlank(value)) {
try {
currentAudioTrack.setBitsperSample(Integer.parseInt(value));
} catch (NumberFormatException nfe) {
Expand Down Expand Up @@ -298,22 +299,42 @@ public synchronized static void parse(DLNAMediaInfo media, InputFile inputFile,
if (subTracks > 0) {
for (int i = 0; i < subTracks; i++) {
currentSubTrack = new DLNAMediaSubtitle();
currentSubTrack.setType(SubtitleType.valueOfLibMediaInfoCodec(MI.Get(text, i, "Format")));
currentSubTrack.setType(SubtitleType.valueOfLibMediaInfoCodec(MI.Get(text, i, "CodecID")));
currentSubTrack.setLang(getLang(MI.Get(text, i, "Language/String")));
value = MI.Get(text, i, "CodecID");
if (isNotBlank(value)) {
currentSubTrack.setType(SubtitleType.valueOfLibMediaInfoCodec(value));
} else {
currentSubTrack.setType(SubtitleType.valueOfLibMediaInfoCodec(MI.Get(text, i, "Format")));
}
currentSubTrack.setLang(getLang(MI.Get(text, i, "Language")));
currentSubTrack.setSubtitlesTrackTitleFromMetadata((MI.Get(text, i, "Title")).trim());
// Special check for OGM: MediaInfo reports specific Audio/Subs IDs (0xn) while mencoder does not
value = MI.Get(text, i, "ID/String");
if (!value.isEmpty()) {
if (value.contains("(0x") && !FormatConfiguration.OGG.equals(media.getContainer())) {
currentSubTrack.setId(getSpecificID(value));
} else {
currentSubTrack.setId(media.getSubtitleTracksList().size());
}
value = MI.Get(text, i, "ID");
if (isNotBlank(value) && value.contains("-") && !(value.contains("-CC") || value.contains("-T") || value.contains("-XDS"))) {
currentSubTrack.setId(getSpecificID(value));
} else {
currentSubTrack.setId(media.getSubtitleTracksList().size());
}

addSub(currentSubTrack, media);
}
} else { // Check for teletext
subTracks = MI.Count_Get(other);
if (subTracks > 0) {
for (int i = 0; i < subTracks; i++) {
currentSubTrack = new DLNAMediaSubtitle();
value = MI.Get(other, i, "Format");
if (value.startsWith("Teletext")) {
currentSubTrack.setType(SubtitleType.valueOfLibMediaInfoCodec(value));
currentSubTrack.setLang(getLang(MI.Get(other, i, "Language")));
value = MI.Get(other, i, "ID");
if (isNotBlank(value) && value.contains("-")) {
currentSubTrack.setId(getSpecificID(value));
} else {
currentSubTrack.setId(media.getSubtitleTracksList().size());
}
addSub(currentSubTrack, media);
}
}
}
}

/*
Expand Down Expand Up @@ -803,16 +824,20 @@ public static int getBitrate(String value) {

public static int getSpecificID(String value) {
// If ID is given as 'streamID-substreamID' use the second (which is hopefully unique).
// For example in vob audio ID can be '189 (0xBD)-32 (0x80)' and text ID '189 (0xBD)-128 (0x20)'
int end = value.lastIndexOf("(0x");
if (end > -1) {
int start = value.lastIndexOf('-') + 1;
value = value.substring(start > end ? 0 : start, end);
// For example in VOB files, audio ID can be '189-128' and text ID '189-32'
if (value.contains("-")) {
value = value.substring(value.lastIndexOf('-') + 1).trim();
} else {
value = value.trim();
}

value = value.trim();
int id = Integer.parseInt(value);
return id;
try {
return Integer.parseInt(value);
} catch (NumberFormatException e) {
LOGGER.debug("Could not parse the stream ID \"{}\": {}", value, e.getMessage());
LOGGER.trace("", e);
return 0;
}
}

public static String getSampleFrequency(String value) {
Expand Down
Loading