From 34e20b5f47aa767828dc8519f8a168b7d68054f6 Mon Sep 17 00:00:00 2001 From: Reinhard Pointner Date: Sun, 2 Oct 2016 01:10:23 +0800 Subject: [PATCH] Fix for unexpected Channels MediaInfo values @see https://www.filebot.net/forums/viewtopic.php?f=6&t=4182 --- source/net/filebot/format/MediaBindingBean.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/net/filebot/format/MediaBindingBean.java b/source/net/filebot/format/MediaBindingBean.java index c5f93cb0..59ba36d4 100644 --- a/source/net/filebot/format/MediaBindingBean.java +++ b/source/net/filebot/format/MediaBindingBean.java @@ -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 -> { - return SLASH.splitAsStream(s).mapToDouble(Double::parseDouble).reduce(0, (a, b) -> a + b); + 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();