Skip to content

Commit f6bfd8e

Browse files
committed
[YouTube] support extracting DRC audio
Implements support for checking whether an extracted audio format is using dynamic range compression (DRC). Ref: https://en.wikipedia.org/wiki/Dynamic_range_compression
1 parent f5676c2 commit f6bfd8e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ public MediaFormat getMediaFormat() {
266266
private AudioTrackType audioTrackType;
267267
@Nullable
268268
private Locale audioLocale;
269+
private boolean isDrc;
269270

270271
public int getBitrate() {
271272
return bitrate;
@@ -647,4 +648,31 @@ public Locale getAudioLocale() {
647648
public void setAudioLocale(@Nullable final Locale audioLocale) {
648649
this.audioLocale = audioLocale;
649650
}
651+
652+
/**
653+
* Whether the audio is using dynamic range compression (DRC).
654+
*
655+
* <p>
656+
* https://en.wikipedia.org/wiki/Dynamic_range_compression
657+
* </p>
658+
*
659+
* @return whether the audio is using DRC
660+
*/
661+
public Boolean isDrc() {
662+
return isDrc;
663+
}
664+
665+
/**
666+
* Sets whether the audio is using dynamic range compression (DRC).
667+
*
668+
* <p>
669+
* https://en.wikipedia.org/wiki/Dynamic_range_compression
670+
* </p>
671+
*
672+
* @param isDrc whether the audio has DRC applied
673+
*/
674+
public void setIsDrc(final Boolean isDrc) {
675+
this.isDrc = isDrc;
676+
}
677+
650678
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,7 @@ private ItagInfo buildAndAddItagInfoToList(
14211421
itagItem.setIndexEnd(Integer.parseInt(indexRange.getString("end", "-1")));
14221422
itagItem.setQuality(formatData.getString("quality"));
14231423
itagItem.setCodec(codec);
1424+
itagItem.setIsDrc(formatData.getBoolean("isDrc", false));
14241425

14251426
if (streamType == StreamType.LIVE_STREAM || streamType == StreamType.POST_LIVE_STREAM) {
14261427
itagItem.setTargetDurationSec(formatData.getInt("targetDurationSec"));

0 commit comments

Comments
 (0)