diff --git a/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java b/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java index d200658..0acde44 100644 --- a/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java +++ b/jave-core/src/main/java/ws/schild/jave/MultimediaObject.java @@ -54,6 +54,12 @@ public void setReadURLOnce(boolean readURLOnce) { private static final Pattern CHANNELS_PATTERN = Pattern.compile("(mono|stereo|quad)", Pattern.CASE_INSENSITIVE); + /** + * This regexp is used to parse the ffmpeg output about the bit depth of an audio stream. + */ + private static final Pattern BIT_DEPTH_PATTERN = + Pattern.compile("(s16|s16p|s32|fltp|dblp|s64)", Pattern.CASE_INSENSITIVE); + /** The locator of the ffmpeg executable used by this extractor. */ private final ProcessLocator locator; @@ -361,6 +367,13 @@ private MultimediaInfo parseMultimediaInfo(String source, RBufferedReader reader audio.setBitRate(bitRate * 1000); parsed = true; } + // Bit depth + m2 = BIT_DEPTH_PATTERN.matcher(token); + if (!parsed && m2.find()) { + String bitDepth = m2.group(1); + audio.setBitDepth(bitDepth); + parsed = true; + } } } //reading audio metadata diff --git a/jave-core/src/main/java/ws/schild/jave/info/AudioInfo.java b/jave-core/src/main/java/ws/schild/jave/info/AudioInfo.java index 2a9ee8c..80edb38 100644 --- a/jave-core/src/main/java/ws/schild/jave/info/AudioInfo.java +++ b/jave-core/src/main/java/ws/schild/jave/info/AudioInfo.java @@ -43,6 +43,10 @@ public class AudioInfo { /** The audio stream (average) bit rate. If less than 0, this information is not available. */ private int bitRate = -1; + + /** The audio stream bit depth. */ + private String bitDepth; + /** The video metadata. */ private Map metadata = new HashMap<>(); @@ -127,6 +131,25 @@ public AudioInfo setBitRate(int bitRate) { return this; } + /** + * Returns the audio stream bit depth. + * + * @return The audio stream bit depth. + */ + public String getBitDepth() { + return bitDepth; + } + + /** + * Sets the audio stream bit depth. + * + * @param bitDepth The audio stream bit depth. + * @return this instance + */ + public void setBitDepth(String bitDepth) { + this.bitDepth = bitDepth; + } + /** * Returns the audio metadata. * @@ -150,14 +173,16 @@ public AudioInfo setMetadata(Map metadata) { @Override public String toString() { return getClass().getName() - + " (decoder=" - + decoder - + ", samplingRate=" - + samplingRate - + ", channels=" - + channels - + ", bitRate=" - + bitRate - + ")"; + + " (decoder=" + + decoder + + ", samplingRate=" + + samplingRate + + ", channels=" + + channels + + ", bitRate=" + + bitRate + + ", bitDepth=" + + bitDepth + + ")"; } -} +} \ No newline at end of file