Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Media Player doesn't reproduce audio from file that was created with mp4box library #342

Open
AlexMixilab opened this issue Jun 16, 2023 · 1 comment

Comments

@AlexMixilab
Copy link

AlexMixilab commented Jun 16, 2023

I am using the mp4box library to create a media file that includes video and audio tracks. I have set up my audio encoder output callback using the following code:
`if (encodingAudioTrack === null) {
let encodingAudioTrackOptions = {
timescale: this.timescale,
samplerate: this.options.audioConfig?.sampleRate,
channel_count: this.options.audioConfig?.numberOfChannels,
samplesize: 16,
hdlr: 'soun',
name: 'SoundHandler',
type: 'mp4a',
brands: ['mp42', 'mp41', 'isom'],
}
encodingAudioTrack = this.file.addTrack(encodingAudioTrackOptions);
}

if (this.previousEncodedAudioChunk) {
let ab = new ArrayBuffer(this.previousEncodedAudioChunk.byteLength);
this.previousEncodedAudioChunk.copyTo(ab);
const sampleDuration = chunk.timestamp - this.previousEncodedAudioChunk.timestamp;
this.file.addSample(encodingAudioTrack, ab, {
dts: this.audioSampleTimestamp,
cts: this.audioSampleTimestamp,
duration: sampleDuration,
});
this.audioChunkCount++;
this.audioSampleTimestamp = this.audioSampleTimestamp + (sampleDuration ?? 0);
}`

This is the config for AudioEncoder from WebCodec API:
audioEncoderConfig = { codec: 'mp4a.40.2', sampleRate: combinedStream.getAudioTracks()[0].getSettings().sampleRate ?? 0, numberOfChannels: combinedStream.getAudioTracks()[0].getSettings().channelCount ?? 0, bitrate: 128_000, }

However, when I save the created file and launch it with Windows 10 Media Player or Movies & TV, the audio doesn't play. MPC_HC Player, on the other hand, opens the file correctly. I noticed that when I check the info with MediaInfo tool, the codec identifier is mp4a instead of mp4a.40.2 that was set.

Am I missing some details or did I set something wrong? I appreciate any help.

@hughfenghen
Copy link

@AlexMixilab FYI #341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants