jv4-demuxer
Advanced tools
Comparing version 1.0.4 to 1.0.5
{ | ||
"name": "jv4-demuxer", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
import { BaseDemuxer, DemuxEvent, DemuxMode } from "./base"; | ||
import { samplingFrequencyIndexMap } from "./util"; | ||
@@ -59,12 +60,14 @@ export interface FlvTag { | ||
numberOfChannels: 1, | ||
sampleRate: 44100, | ||
sampleRate: 8000, | ||
}; | ||
//TODO: parse audio config | ||
if (this.audioEncoderConfig.codec == "aac") { | ||
this.audioEncoderConfig.numberOfChannels = ((data[3] >> 3) & 0x0F) //声道 | ||
this.audioEncoderConfig.sampleRate = samplingFrequencyIndexMap[((data[2]&0x7)<<1)|(data[3]>>7)]) | ||
} | ||
} | ||
if (this.audioEncoderConfig.codec == "aac" && data[1] == 0x00) { | ||
this.audioEncoderConfig.extraData = data.subarray(2); | ||
this.emit( | ||
DemuxEvent.AUDIO_ENCODER_CONFIG_CHANGED, | ||
data.subarray(2) | ||
this.audioEncoderConfig | ||
); | ||
@@ -71,0 +74,0 @@ if (this.mode == DemuxMode.PULL) |
@@ -107,6 +107,7 @@ import { BaseDemuxer, DemuxEvent, DemuxMode } from "./base"; | ||
const audio = this.parsePESPacket(apes); | ||
if (this.audioEncoderConfig?.codec == "aac" && this.audioEncoderConfig.numberOfChannels == 0) { | ||
if (this.audioEncoderConfig?.codec == "aac" && !this.audioEncoderConfig?.extraData) { | ||
const asc = adtsToAsc(audio.subarray(7)); | ||
this.audioEncoderConfig = { | ||
codec: "aac", | ||
extraData: asc.audioSpecificConfig, | ||
sampleRate: asc.sampleRate, | ||
@@ -117,3 +118,3 @@ numberOfChannels: asc.channel, | ||
DemuxEvent.AUDIO_ENCODER_CONFIG_CHANGED, | ||
asc.audioSpecificConfig | ||
this.audioEncoderConfig | ||
); | ||
@@ -199,3 +200,3 @@ } | ||
}; | ||
this.emit(DemuxEvent.VIDEO_ENCODER_CONFIG_CHANGED); | ||
this.emit(DemuxEvent.VIDEO_ENCODER_CONFIG_CHANGED, this.videoEncoderConfig); | ||
} else if (elementaryStreamID >= 0xc0 && elementaryStreamID <= 0xdf) { | ||
@@ -207,6 +208,8 @@ this.audioStreamType = streamType; | ||
"unknown", | ||
numberOfChannels: 0, | ||
sampleRate: 0, | ||
numberOfChannels: 1, | ||
sampleRate: 8000, | ||
}; | ||
this.emit(DemuxEvent.AUDIO_ENCODER_CONFIG_CHANGED); | ||
if (this.audioEncoderConfig.codec != "aac") { | ||
this.emit(DemuxEvent.AUDIO_ENCODER_CONFIG_CHANGED); | ||
} | ||
} | ||
@@ -213,0 +216,0 @@ if (l <= index + 1) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16666
474