1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-24 00:38:52 -05:00

Fix for unexpected Channels MediaInfo values

@see https://www.filebot.net/forums/viewtopic.php?f=6&t=4182
This commit is contained in:
Reinhard Pointner 2016-10-02 01:10:23 +08:00
parent bc421e6b8a
commit 34e20b5f47

View File

@ -385,7 +385,7 @@ public class MediaBindingBean {
String channels = getMediaInfo(StreamKind.Audio, 0, "Channel(s)_Original", "Channel(s)");
// get first number, e.g. 6ch
return SPACE.splitAsStream(channels).findFirst().get() + "ch";
return SPACE.splitAsStream(channels).filter(DIGIT.asPredicate()).findFirst().get() + "ch";
}
@Define("channels")
@ -394,7 +394,11 @@ public class MediaBindingBean {
// e.g. ChannelPositions/String2: 3/2/2.1 / 3/2/0.1 (one audio stream may contain multiple multi-channel streams)
double d = SPACE.splitAsStream(channels).mapToDouble(s -> {
try {
return SLASH.splitAsStream(s).mapToDouble(Double::parseDouble).reduce(0, (a, b) -> a + b);
} catch (NumberFormatException e) {
return 0;
}
}).filter(it -> it > 0).max().getAsDouble();
return BigDecimal.valueOf(d).setScale(1, RoundingMode.HALF_UP).toPlainString();