流利的ffmpeg如何用户保存回调

Fluent ffmpeg how to user save callback

我正在使用 fluent-ffmpeg GIT 我想进一步处理保存的文件。但是保存没有任何回调。我怎样才能使用 promise 保存的文件。 我的密码是

ffmpeg(filename)
    .toFormat('mp3')
    .on('error', (err) => {
       console.log('An error occurred: ' + err.message);
    })
    .on('progress', (progress) => {
        console.log('Processing: ' + progress.targetSize + ' KB converted');
})
.on('end', () => {
        console.log('Processing finished !');
})
.save(`./${newname}.mp3`)

我的问题是 "save" 函数没有回调。那么我怎样才能再次将输出保存到 S3 上呢?

save 方法不需要自己的回调。如文档所述,

save(filename): save the output to a file

Starts ffmpeg processing and saves the output to a file.

Note: the save() method is actually syntactic sugar for calling both output() and run().

<...>

The end event is emitted when processing has finished. Listeners receive ffmpeg standard output and standard error as arguments, except when generating thumbnails (see below), in which case they receive an array of the generated filenames.

流可以像任何其他流一样被承诺:

new Promise((resolve, reject) => {
    ffmpeg(filename)
    .toFormat('mp3')
    .on('error', reject)
    .on('progress', (progress) => {
        console.log('Processing: ' + progress.targetSize + ' KB converted');
    })
    .on('end', resolve)
    .save(`./${newname}.mp3`)
});