diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/worker/processFiles.js | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/worker/processFiles.js b/lib/worker/processFiles.js index 26fdb0e..21021b5 100644 --- a/lib/worker/processFiles.js +++ b/lib/worker/processFiles.js @@ -47,6 +47,7 @@ function processAudio(file) { return new Promise ( (resolve, reject) => { cacheFfprobe(file, fullPath) + .then(() => { return convertToAiff(fullPath) }) .then(() => { return processSpectrum(fullPath) }) .then(() => { return trimSpectrum(fullPath) }) .then(() => { return convertToMp3(fullPath) }) @@ -58,7 +59,9 @@ function processAudio(file) { function processSpectrum(fullPath) { return new Promise ( (resolve, reject) => { console.log('process spectrum') - execFile(process.env.PYTHON_BINARY, ['./python/spectrum.py', fullPath], (err, stdout, stderr) => { + const aiffPath = fullPath + '.aiff' + const pngPath = fullPath + '.png' + execFile(process.env.PYTHON_BINARY, ['./python/spectrum.py', aiffPath, pngPath], (err, stdout, stderr) => { // console.log('spectrum done') resolve() }) @@ -84,6 +87,16 @@ function cacheFfprobe(file, fullPath) { }) }) } +function convertToAiff(fullPath) { + return new Promise ( (resolve, reject) => { + console.log('convert to aiff') + const aiffPath = fullPath + '.aiff' + execFile(process.env.FFMPEG_BINARY, ['-y', '-i', fullPath, '-acodec', 'pcm_s16le', '-ar', '44100', aiffPath], (err, stdout, stderr) => { + // console.log(stdout, stderr) + resolve() + }) + }) +} function convertToMp3(fullPath) { return new Promise ( (resolve, reject) => { console.log('convert to mp3') |
