Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from deenine/rh1-upload
PoC Download function
- Loading branch information
Showing
11 changed files
with
367 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ npm-debug.log | |
npm-debug.log.* | ||
thumbs.db | ||
!.gitkeep | ||
design-files | ||
design-files | ||
resources/netmd-py/*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const fs = require('fs-extra') | ||
const ffmpegPath = require('@ffmpeg-installer/ffmpeg').path.replace('app.asar', 'app.asar.unpacked') | ||
const ffmpeg = require('fluent-ffmpeg') | ||
ffmpeg.setFfmpegPath(ffmpegPath) | ||
|
||
/** | ||
* Convert audio file to WAV file using ffmpeg | ||
* This MUST be 44100 and 16bit for the atrac encoder to work | ||
*/ | ||
export async function convertAudio (source, dest, format) { | ||
return new Promise(async (resolve, reject) => { | ||
// Start conversion | ||
var codec = ['-acodec', 'pcm_s16le'] | ||
console.log('Starting WAV conversion process using ffmpeg: ' + source + ' --> ' + dest) | ||
switch (format) { | ||
case ('FLAC'): | ||
codec = ['-acodec', 'flac'] | ||
break | ||
case ('MP3'): | ||
codec = ['-acodec', 'mp3', '-b:a', '320k'] | ||
break | ||
} | ||
ffmpeg(source) | ||
.output(dest) | ||
.outputOption(codec) | ||
.audioFrequency(44100) | ||
.on('start', function (commandLine) { | ||
console.log('Spawned Ffmpeg with command: ', commandLine) | ||
}) | ||
.on('progress', function (progress) { | ||
console.log('Processing: ' + progress.timemark + ' done ' + progress.targetSize + ' kilobytes') | ||
}) | ||
// If successful, resolve | ||
.on('end', function () { | ||
console.log('ffmpeg completed successfully') | ||
resolve() | ||
}) | ||
// Reject if we get any errors | ||
.on('error', function (err) { | ||
console.log('ffmpeg error: ' + err.message) | ||
reject(err.message) | ||
}) | ||
.run() | ||
}) | ||
} | ||
|
||
/** | ||
* Make sure temp directory actually exists, if not create it | ||
*/ | ||
export function ensureDirSync (dirpath) { | ||
try { | ||
fs.mkdirSync(dirpath, { recursive: true }) | ||
} catch (err) { | ||
if (err.code !== 'EEXIST') throw err | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.