Skip to content

Commit

Permalink
Merge pull request #242 from a-schild/master
Browse files Browse the repository at this point in the history
Merge master changes into develop
  • Loading branch information
a-schild authored Oct 14, 2023
2 parents da95a70 + ec0ef8b commit f71ee31
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
13 changes: 13 additions & 0 deletions jave-core/src/main/java/ws/schild/jave/MultimediaObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
45 changes: 35 additions & 10 deletions jave-core/src/main/java/ws/schild/jave/info/AudioInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> metadata = new HashMap<>();

Expand Down Expand Up @@ -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.
*
Expand All @@ -150,14 +173,16 @@ public AudioInfo setMetadata(Map<String, String> 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
+ ")";
}
}
}

0 comments on commit f71ee31

Please sign in to comment.