[YouTube] Fix extraction of fps, audioSampleRate and audioChannels fields for ItagItems of live streams and post live streams
These values were only set before for video streams. A fallback for the audio channels count has been added, in order to prevent exceptions when generating DASH manifests of audio streams: the fallback value is 2, because most audio streams on YouTube have 2 audio channels.
This commit is contained in:
parent
c8a77da2ab
commit
e960a417ec
1 changed files with 10 additions and 3 deletions
|
@ -1358,13 +1358,20 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
if (streamType == StreamType.LIVE_STREAM || streamType == StreamType.POST_LIVE_STREAM) {
|
||||
itagItem.setTargetDurationSec(formatData.getInt("targetDurationSec"));
|
||||
} else if (itagType == ItagItem.ItagType.VIDEO
|
||||
|| itagType == ItagItem.ItagType.VIDEO_ONLY) {
|
||||
}
|
||||
|
||||
if (itagType == ItagItem.ItagType.VIDEO || itagType == ItagItem.ItagType.VIDEO_ONLY) {
|
||||
itagItem.setFps(formatData.getInt("fps"));
|
||||
} else if (itagType == ItagItem.ItagType.AUDIO) {
|
||||
// YouTube return the audio sample rate as a string
|
||||
itagItem.setSampleRate(Integer.parseInt(formatData.getString("audioSampleRate")));
|
||||
itagItem.setAudioChannels(formatData.getInt("audioChannels"));
|
||||
itagItem.setAudioChannels(formatData.getInt("audioChannels",
|
||||
// Most audio streams have two audio channels, so use this value if the real
|
||||
// count cannot be extracted
|
||||
// Doing this prevents an exception when generating the
|
||||
// AudioChannelConfiguration element of DASH manifests of audio streams in
|
||||
// YoutubeDashManifestCreatorUtils
|
||||
2));
|
||||
}
|
||||
|
||||
// YouTube return the content length and the approximate duration as strings
|
||||
|
|
Loading…
Reference in a new issue