Add atracdenc logging. Add sample rate conversion

44100Hz sample rate is required for atracdenc encoding
This commit is contained in:
Stefano Brilli 2020-03-23 14:16:46 +01:00
parent 4fb407454b
commit 18c7f91c89
2 changed files with 4 additions and 2 deletions

View File

@ -38,12 +38,14 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
(self as any).Module().then((m: any) => { (self as any).Module().then((m: any) => {
Module = m; Module = m;
self.postMessage({ action: 'init' }); self.postMessage({ action: 'init' });
Module.setLogger((msg: string, stream: string) => console.log(`${stream}: ${msg}`));
}); });
} else if (action === 'encode') { } else if (action === 'encode') {
const { bitrate, data } = others; const { bitrate, data } = others;
const inWavFile = `inWavFile.wav`; const inWavFile = `inWavFile.wav`;
const outAt3File = `outAt3File.aea`; const outAt3File = `outAt3File.aea`;
Module.FS.writeFile(`${inWavFile}`, new Uint8Array(data)); const dataArray = new Uint8Array(data);
Module.FS.writeFile(`${inWavFile}`, dataArray);
Module.callMain([`-e`, `atrac3`, `-i`, inWavFile, `-o`, outAt3File, `--bitrate`, bitrate]); Module.callMain([`-e`, `atrac3`, `-i`, inWavFile, `-o`, outAt3File, `--bitrate`, bitrate]);
// Read file and trim header (96 bytes) // Read file and trim header (96 bytes)

View File

@ -87,7 +87,7 @@ export class FFMpegAudioExportService implements AudioExportService {
return data.buffer; return data.buffer;
} else { } else {
const outFileName = `${this.outFileNameNoExt}.wav`; const outFileName = `${this.outFileNameNoExt}.wav`;
await this.ffmpegProcess.transcode(this.inFileName, outFileName, '-f wav'); await this.ffmpegProcess.transcode(this.inFileName, outFileName, '-f wav -ar 44100');
let { data } = await this.ffmpegProcess.read(outFileName); let { data } = await this.ffmpegProcess.read(outFileName);
let bitrate: string = `0`; let bitrate: string = `0`;
switch (format) { switch (format) {