summaryrefslogtreecommitdiff
path: root/lib/worker/processFiles.js
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2017-07-02 22:49:26 +0200
committerJules Laplace <julescarbon@gmail.com>2017-07-02 22:49:26 +0200
commitdb3a5fcd8edaa45ef05a6250e7f9452f0ed87250 (patch)
tree871703028cef31309102d452197d737bc5cc76e8 /lib/worker/processFiles.js
parentef0d6a05a1717b9cb9b52fca9285c9ba8c191b0c (diff)
resample to 16bit 44100hz aiff
Diffstat (limited to 'lib/worker/processFiles.js')
-rw-r--r--lib/worker/processFiles.js15
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')