From b42cf01fe9c310d794a35e4fba47367067b2c689 Mon Sep 17 00:00:00 2001 From: wudechang Date: Wed, 4 Sep 2024 19:59:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20mp3=E9=9F=B3=E9=A2=91=E6=B2=A1=E5=A3=B0?= =?UTF-8?q?=E9=9F=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/xgplayer-transmuxer/src/codec/mpeg.js | 8 +++++++- packages/xgplayer-transmuxer/src/mpeg-ts/index.js | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/xgplayer-transmuxer/src/codec/mpeg.js b/packages/xgplayer-transmuxer/src/codec/mpeg.js index 6627f4bac..cdb6bbb41 100644 --- a/packages/xgplayer-transmuxer/src/codec/mpeg.js +++ b/packages/xgplayer-transmuxer/src/codec/mpeg.js @@ -1,3 +1,5 @@ +import { isFirefox } from '../utils' + const BitratesMap = [ 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 32, 40, 48, 56, 64, 80, @@ -83,7 +85,11 @@ export class MPEG { track.config = [] track.channelCount = header.channelCount track.sampleRate = header.sampleRate - track.container = 'audio/mpeg' + if (isFirefox) { + track.codec = 'mp3' + } else { + track.container = 'audio/mpeg' + } track.samples.push(sample) return { length: header.frameLength } diff --git a/packages/xgplayer-transmuxer/src/mpeg-ts/index.js b/packages/xgplayer-transmuxer/src/mpeg-ts/index.js index b9665b14d..74c70ca9c 100644 --- a/packages/xgplayer-transmuxer/src/mpeg-ts/index.js +++ b/packages/xgplayer-transmuxer/src/mpeg-ts/index.js @@ -101,8 +101,10 @@ export class TsDemuxer { break case 0x03: case 0x04: - audioTrack.pid = audioPid = esPid - audioTrack.codecType = AudioCodecType.MP3 + if (audioTrack.pid === -1) { + audioTrack.pid = audioPid = esPid + audioTrack.codecType = AudioCodecType.MP3 + } break case 0x1b: // AVC if (videoPid !== -1) break