Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge master changes into develop #242

Merged
merged 2 commits into from
Oct 14, 2023
Merged
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
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
+ ")";
}
}
}
Loading