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
|
//convert to mp3
|
||||||
let dir = path.dirname(audiofile.filepath);
|
let dir = path.dirname(audiofile.filepath);
|
||||||
try {
|
function converter() {
|
||||||
var process = new ffmpeg(audiofile.filepath);
|
return new Promise((resolve,reject) => {
|
||||||
process.then(function (video) {
|
var process = new ffmpeg(audiofile.filepath);
|
||||||
// Callback mode
|
process.then(function (video) {
|
||||||
video.fnExtractSoundToMP3(dir + '/converted.mp3', function (error, file) {
|
// Callback mode
|
||||||
if (!error)
|
video.fnExtractSoundToMP3(dir + '/converted.mp3', function (error, file) {
|
||||||
console.log('Audio file: ' + file);
|
if (!error) {
|
||||||
});
|
console.log('Audio file: ' + file);
|
||||||
}, function (err) {
|
resolve()
|
||||||
console.log('Error: ' + err);
|
}
|
||||||
});
|
});
|
||||||
} catch (e) {
|
}, function (err) {
|
||||||
console.log(e.code);
|
console.log('Error: ' + err);
|
||||||
console.log(e.msg);
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
// 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 file = await folder.createFile(audiofile.filename, await fs.readFile(audiofile.filepath));
|
||||||
// const text = await folder.createFile("message.txt", Buffer.from(audiofile.fields.message.value));
|
// const text = await folder.createFile("message.txt", Buffer.from(audiofile.fields.message.value));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue