File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
packages/xgplayer-transmuxer/src/mpeg-ts Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 11import { AudioSample , WarningType } from '../model'
22import { AAC } from '../codec'
33import { isSafari } from '../utils'
4+ import { AudioCodecType } from '../model/types'
45
56const LARGE_AV_FIRST_FRAME_GAP = 90000 / 2 // 500ms
67const AUDIO_GAP_OVERLAP_THRESHOLD_COUNT = 3
@@ -230,6 +231,23 @@ export class TsFixer {
230231 const samples = audioTrack . samples
231232
232233 if ( ! samples . length ) return
234+ if ( audioTrack . codecType === AudioCodecType . MP3 ) {
235+ if ( this . lastAudioSample ) {
236+ samples . unshift ( this . lastAudioSample )
237+ }
238+ for ( let index = 0 ; index < samples . length ; index ++ ) {
239+ const x = samples [ index ]
240+ if ( samples [ index + 1 ] ) {
241+ x . duration = samples [ index + 1 ] . pts - x . pts
242+ } else {
243+ break
244+ }
245+ x . pts -= this . _baseDts
246+ x . dts = x . pts
247+ }
248+ this . lastAudioSample = samples . pop ( )
249+ return
250+ }
233251 samples . forEach ( x => {
234252 x . pts -= this . _needForceFixLargeGap ? this . _baseAudioDts : this . _baseDts
235253 x . dts = x . pts
You can’t perform that action at this time.
0 commit comments