Add support for atrac3 encoded tracks

This commit is contained in:
Stefano Brilli 2021-09-18 15:31:12 +02:00
parent 254c06c74a
commit b7c3aaddf6
3 changed files with 44 additions and 15 deletions

View File

@ -2,20 +2,22 @@
# This is just an experiment. Might not work at all on your hardware # This is just an experiment. Might not work at all on your hardware
apt update apt update
apt install wine-stable DEBIAN_FRONTEND=noninteractive apt install -y wine-stable wget vim
wget https://github.com/cskau/atrac3util/releases/download/v0.0.1/atrac3util.exe wget https://github.com/cskau/atrac3util/releases/download/v0.0.1/atrac3util.exe
wget https://dl.winehq.org/wine/wine-mono/4.9.4/wine-mono-4.9.4.msi wget https://dl.winehq.org/wine/wine-mono/4.9.4/wine-mono-4.9.4.msi
WINEARCH=win32 WINEPREFIX=~/.wine32 wineboot # WINEARCH=win32 WINEPREFIX=~/.wine32 wineboot
wineboot wineboot
wine msiexec /i wine-mono-4.9.4.msi wine msiexec /i wine-mono-4.9.4.msi
wine64 msiexec /i wine-mono-4.9.4.msi wine64 msiexec /i wine-mono-4.9.4.msi
wget https://samples.ffmpeg.org/A-codecs/ATRAC3/atrac3.acm wget https://samples.ffmpeg.org/A-codecs/ATRAC3/atrac3.acm
cp atrac3.acm ~/.wine/drive_c/windows/system32/ cp atrac3.acm ~/.wine/drive_c/windows/system32/
cp atrac3.acm ~/.wine/drive_c/windows/syswow64/ cp atrac3.acm ~/.wine/drive_c/windows/syswow64/
vi ~/.wine/drive_c/windows/system.ini vi ~/.wine/drive_c/windows/system.ini #msacm.at3=atrac3.acm
ls ls
wine64 atrac3util.exe wine64 atrac3util.exe
wine atrac3util.exe wine atrac3util.exe
apt-get install mono-complete apt-get install mono-complete
git clone https://github.com/cskau/atrac3util.git git clone https://github.com/cskau/atrac3util.git
cd atrac3util/ cd atrac3util/
@ -23,6 +25,7 @@ mcs -out:atrac3util.exe main.cs acm.cs
ls ls
wine atrac3util.exe wine atrac3util.exe
wine64 atrac3util.exe wine64 atrac3util.exe
dpkg --add-architecture i386 && apt-get update && apt-get install wine32 dpkg --add-architecture i386 && apt-get update && apt-get install wine32
wine64 atrac3util.exe wine64 atrac3util.exe
ls .. ls ..
@ -47,10 +50,24 @@ cd atrac3util/
mcs -out:atrac3util.exe main.cs acm.cs mcs -out:atrac3util.exe main.cs acm.cs
# dockerfile # dockerfile
dpkg --add-architecture i386
apt update apt update
apt install wine-stable DEBIAN_FRONTEND=noninteractive apt install -y wine32 wget
wineboot wineboot
wget https://dl.winehq.org/wine/wine-mono/4.9.4/wine-mono-4.9.4.msi wget https://dl.winehq.org/wine/wine-mono/4.9.4/wine-mono-4.9.4.msi
wine msiexec /i wine-mono-4.9.4.msi wine msiexec /i wine-mono-4.9.4.msi
wget https://samples.ffmpeg.org/A-codecs/ATRAC3/atrac3.acm
cp atrac3.acm ~/.wine/drive_c/windows/system32/ cp atrac3.acm ~/.wine/drive_c/windows/system32/
echo "msacm.at3=atrac3.acm" >> ~/.wine/drive_c/windows/system.ini echo "msacm.at3=atrac3.acm" >> ~/.wine/drive_c/windows/system.ini
wget https://github.com/cskau/atrac3util/releases/download/v0.0.1/atrac3util.exe
wine atrac3util.exe prova.wav prova.at3
# bash idea
ID=$(docker run -itd atrac3) # https://stackoverflow.com/questions/44577344/piping-docker-run-container-id-to-docker-exec
# for each file
docker cp @file $ID:/tmp/file # https://stackoverflow.com/questions/22907231/how-to-copy-files-from-host-to-docker-container
docker exec -it $ID wine atrac3util.exe -lp2 /tmp/@file /tmp/@file.at3
docker cp $ID:/tmp/file/@file.at3 ./file.at3
docker stop $ID

View File

@ -534,12 +534,18 @@ export function convertAndUpload(files: File[], requestedFormat: UploadFormat, t
let error: any; let error: any;
let errorMessage = ``; let errorMessage = ``;
let i = 1; let i = 1;
let failedConversion: File[] = [];
for await (let item of conversionIterator(files)) { for await (let item of conversionIterator(files)) {
if (hasUploadBeenCancelled()) { if (hasUploadBeenCancelled()) {
break; break;
} }
const { file, data, format } = item; const { file, data, format } = item;
if (data === null) {
console.error(`Conversion failed for file: ${file.name}`);
failedConversion.push(file);
continue;
}
let title = file.name; let title = file.name;
try { try {

View File

@ -49,6 +49,9 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
const inWavFile = `inWavFile.wav`; const inWavFile = `inWavFile.wav`;
const outAt3File = `outAt3File.aea`; const outAt3File = `outAt3File.aea`;
const dataArray = new Uint8Array(data); const dataArray = new Uint8Array(data);
let result = null;
try {
Module.FS.writeFile(`${inWavFile}`, dataArray); 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]);
@ -60,14 +63,17 @@ if (typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScop
Module.FS.read(outAt3FileStream, tmp, 0, tmp.length, 96); Module.FS.read(outAt3FileStream, tmp, 0, tmp.length, 96);
Module.FS.close(outAt3FileStream); Module.FS.close(outAt3FileStream);
let result = tmp.buffer; result = tmp.buffer;
} catch (err) {
console.error(`AtracdencProcess error: `, err);
}
self.postMessage( self.postMessage(
{ {
action: 'encode', action: 'encode',
result, result,
}, },
[result] result ? [result] : []
); );
} }
}; };