[英]How to obtain the stderr on node-fluent-ffmpeg
現在,不推薦使用saveToFile回調參數:
FfmpegCommand.prototype.saveToFile = function(targetfile, callback) {
if (callback) {
this.options.logger.warn('saveToFile callback is deprecated, use \'end\' and \'error\' events instead');
我從這里更改了代碼:
new ffmpeg({ source: source })
.toFormat('ogg')
.saveToFile(path.normalize(targetFile), function(stdout, stderr) {
console.log('stdout', stdout);
console.log('stderr', stderr);
});
對此:
new ffmpeg({ source: source })
.toFormat('ogg')
.on('end', function() {
console.log('file has been converted succesfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
.saveToFile(path.normalize(targetFile));
但是我不知道如何獲得舊代碼給我的stderr作為參數(stderr)。 我知道我可以從on'error'事件中獲取錯誤消息,但是我希望獲得stderr來獲取有關出了什么問題的更深入的信息。
提前致謝。
您只需將帶有stdout和stderr的函數作為.on('error')事件的參數移動,如下所示:
.on('error', function(err, stdout, stderr) {
console.log(err.message); //this will likely return "code=1" not really useful
console.log("stdout:\n" + stdout);
console.log("stderr:\n" + stderr); //this will contain more detailed debugging info
})
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.