use*_*842 3 transcode ffmpeg node.js
我在一次噩梦中试图解决这个问题。昨天我问了一个问题,但到目前为止,长话短说,我一生无法解决。
我要做的就是在node.js应用程序中使用FFmpeg将.avi文件转码为.flv文件,这仅适用于FFmpeg的命令行,而在应用程序中无效,这是代码:
var ffmpeg = require('fluent-ffmpeg');
//make sure you set the correct path to your video file
var proc = new ffmpeg({ source: 'C:/Users/Jay/Documents/movie/drop.avi', nolog: true });
//Set the path to where FFmpeg is installed
proc.setFfmpegPath("C:\\Users\\Jay\\Documents\\FFMPEG\\bin");
proc
//set the size
//.withSize('50%') <-- error appears after this line
// set fps
//.withFps(24)
// set output format to force
//.toFormat('flv')
// setup event handlers
.on('end', function() {
console.log('file has been converted successfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to file <-- the new file I want -->
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
Run Code Online (Sandbox Code Playgroud)
该错误出现在上面指定的行上,不是红色书写的错误,而是简单的说:
an error happened: spawn ENOENT
Run Code Online (Sandbox Code Playgroud)
有人遇到过这个吗?
Ben Fortune为我修复了该错误,结果我忘了在安装FFmpeg的路径中指定ffmpeg.exe。这是代码的更新版本:
var ffmpeg = require('fluent-ffmpeg');
//make sure you set the correct path to your video file
var proc = new ffmpeg({ source: 'C:/Users/Jay/Documents/movie/drop.avi', nolog: true });
//Set the path to where FFmpeg is installed
proc.setFfmpegPath("C:\\Users\\Jay\\Documents\\FFMPEG\\bin\\ffmpeg.exe"); //I forgot to include "ffmpeg.exe"
proc
//set the size
.withSize('50%')
// set fps
.withFps(24)
// set output format to force
.toFormat('flv')
// setup event handlers
.on('end', function() {
console.log('file has been converted successfully');
})
.on('error', function(err) {
console.log('an error happened: ' + err.message);
})
// save to file <-- the new file I want -->
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9068 次 |
| 最近记录: |