Skip to content

Commit

Permalink
fix: mp3音频没声音
Browse files Browse the repository at this point in the history
  • Loading branch information
wudechang authored and llftt committed Sep 5, 2024
1 parent f487498 commit b42cf01
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/xgplayer-transmuxer/src/codec/mpeg.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 }
Expand Down
6 changes: 4 additions & 2 deletions packages/xgplayer-transmuxer/src/mpeg-ts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b42cf01

Please sign in to comment.