From 34b69fa3b03c4cb1a0351f8ea81fd39510657b80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Velad=20Galv=C3=A1n?= Date: Tue, 7 Jan 2025 13:24:05 +0100 Subject: [PATCH] fix(HLS): Fix audio detection when there is no audio data but it appears in PMT (#7838) --- lib/media/segment_utils.js | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/media/segment_utils.js b/lib/media/segment_utils.js index 8fbcb248f0..058b661af3 100644 --- a/lib/media/segment_utils.js +++ b/lib/media/segment_utils.js @@ -64,24 +64,34 @@ shaka.media.SegmentUtils = class { switch (tsCodecs.audio) { case 'aac': case 'aac-loas': - codecs.push('mp4a.40.2'); - hasAudio = true; + if (tsParser.getAudioData().length) { + codecs.push('mp4a.40.2'); + hasAudio = true; + } break; case 'mp3': - codecs.push('mp4a.40.34'); - hasAudio = true; + if (tsParser.getAudioData().length) { + codecs.push('mp4a.40.34'); + hasAudio = true; + } break; case 'ac3': - codecs.push('ac-3'); - hasAudio = true; + if (tsParser.getAudioData().length) { + codecs.push('ac-3'); + hasAudio = true; + } break; case 'ec3': - codecs.push('ec-3'); - hasAudio = true; + if (tsParser.getAudioData().length) { + codecs.push('ec-3'); + hasAudio = true; + } break; case 'opus': - codecs.push('opus'); - hasAudio = true; + if (tsParser.getAudioData().length) { + codecs.push('opus'); + hasAudio = true; + } break; } }