test
This commit is contained in:
parent
53495411f3
commit
793037d07b
1 changed files with 15 additions and 17 deletions
32
server.js
32
server.js
|
|
@ -141,24 +141,22 @@ fastify.post("/", async function (request, reply) {
|
|||
|
||||
//convert to mp3
|
||||
let dir = path.dirname(audiofile.filepath);
|
||||
try {
|
||||
var process = new ffmpeg(audiofile.filepath);
|
||||
process.then(function (video) {
|
||||
// Callback mode
|
||||
video.fnExtractSoundToMP3(dir + '/converted.mp3', function (error, file) {
|
||||
if (!error)
|
||||
console.log('Audio file: ' + file);
|
||||
});
|
||||
}, function (err) {
|
||||
console.log('Error: ' + err);
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e.code);
|
||||
console.log(e.msg);
|
||||
function converter() {
|
||||
return new Promise((resolve,reject) => {
|
||||
var process = new ffmpeg(audiofile.filepath);
|
||||
process.then(function (video) {
|
||||
// Callback mode
|
||||
video.fnExtractSoundToMP3(dir + '/converted.mp3', function (error, file) {
|
||||
if (!error) {
|
||||
console.log('Audio file: ' + file);
|
||||
resolve()
|
||||
}
|
||||
});
|
||||
}, function (err) {
|
||||
console.log('Error: ' + err);
|
||||
});
|
||||
});
|
||||
}
|
||||
// await new ffmpeg(audiofile.filepath)
|
||||
//
|
||||
// await util.promisify((await new ffmpeg(name)).fnExtractSoundToMP3("converted.mp3"));
|
||||
|
||||
const file = await folder.createFile(audiofile.filename, await fs.readFile(audiofile.filepath));
|
||||
// const text = await folder.createFile("message.txt", Buffer.from(audiofile.fields.message.value));
|
||||
|
|
|
|||
Loading…
Reference in a new issue