带有node.js的FFmpeg。将文件转换为另一种格式

带有node.js的FFmpeg。将文件转换为另一种格式,node.js,ffmpeg,transcode,Node.js,Ffmpeg,Transcode,对此有点问题,我有一个.avi文件,我想在其中使用FFmpeg将其转换为.flv文件,以下是我到目前为止得到的: 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 th

对此有点问题,我有一个.avi文件,我想在其中使用FFmpeg将其转换为.flv文件,以下是我到目前为止得到的:

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
.setFfmpegPath("C:\Users\Jay\Documents\FFMPEG")

//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');
var-ffmpeg=require('fluent-ffmpeg');
//确保为视频文件设置了正确的路径
var proc=new ffmpeg({source:'C:/Users/Jay/Documents/movie/drop.avi',nolog:true})
//设置安装FFmpeg的路径
.setFfmpegPath(“C:\Users\Jay\Documents\FFMPEG”)
//设定大小
.withSize('50%”)
//设置fps
.带FPS(24)
//将输出格式设置为强制
.toFormat(“flv”)
//设置事件处理程序
.on('end',function(){
log('文件已成功转换');
})
.on('error',函数(err){
log('发生错误:'+err.message);
})
//保存到文件
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
这看起来很简单,我可以通过FFmpeg命令行来完成,但我正在尝试让它在node.js应用程序中工作,下面是它返回的错误:

C:\Users\Jay\workspace\FFMPEGtest\test.js:17
.withSize('50%')
 ^
TypeError: Cannot call method 'withSize' of undefined
    at Object.<anonymous> (C:\Users\Jay\workspace\FFMPEGtest\test.js:17:2)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:906:3
C:\Users\Jay\workspace\FFMPEGtest\test.js:17
.withSize('50%”)
^
TypeError:无法调用未定义的方法“withSize”
反对。(C:\Users\Jay\workspace\FFMPEGtest\test.js:17:2)
在模块处编译(Module.js:456:26)
在Object.Module.\u extensions..js(Module.js:474:10)
在Module.load(Module.js:356:32)
在Function.Module.\u加载(Module.js:312:12)
位于Function.Module.runMain(Module.js:497:10)
启动时(node.js:119:16)
在node.js:906:3
它对每个内置FFmpeg函数(.toFormat、.withFPS等)抛出相同的错误

如果有人对此有解决方案,我将非常感谢它

setFfmpegPath()
不会返回此的实例,如源代码所示 这意味着你不能把方法链起来

换成

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")

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');
var-ffmpeg=require('fluent-ffmpeg');
//确保为视频文件设置了正确的路径
var proc=new ffmpeg({source:'C:/Users/Jay/Documents/movie/drop.avi',nolog:true})
//设置安装FFmpeg的路径
进程setFfmpegPath(“C:\\Users\\Jay\\Documents\\FFMPEG”)
过程
//设定大小
.withSize('50%”)
//设置fps
.带FPS(24)
//将输出格式设置为强制
.toFormat(“flv”)
//设置事件处理程序
.on('end',function(){
log('文件已成功转换');
})
.on('error',函数(err){
log('发生错误:'+err.message);
})
//保存到文件
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
setFfmpegPath()
不返回此的实例,如源代码中所示 这意味着你不能把方法链起来

换成

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")

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');
var-ffmpeg=require('fluent-ffmpeg');
//确保为视频文件设置了正确的路径
var proc=new ffmpeg({source:'C:/Users/Jay/Documents/movie/drop.avi',nolog:true})
//设置安装FFmpeg的路径
进程setFfmpegPath(“C:\\Users\\Jay\\Documents\\FFMPEG”)
过程
//设定大小
.withSize('50%”)
//设置fps
.带FPS(24)
//将输出格式设置为强制
.toFormat(“flv”)
//设置事件处理程序
.on('end',function(){
log('文件已成功转换');
})
.on('error',函数(err){
log('发生错误:'+err.message);
})
//保存到文件
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
setFfmpegPath()
不返回此的实例,如源代码中所示 这意味着你不能把方法链起来

换成

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")

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');
var-ffmpeg=require('fluent-ffmpeg');
//确保为视频文件设置了正确的路径
var proc=new ffmpeg({source:'C:/Users/Jay/Documents/movie/drop.avi',nolog:true})
//设置安装FFmpeg的路径
进程setFfmpegPath(“C:\\Users\\Jay\\Documents\\FFMPEG”)
过程
//设定大小
.withSize('50%”)
//设置fps
.带FPS(24)
//将输出格式设置为强制
.toFormat(“flv”)
//设置事件处理程序
.on('end',function(){
log('文件已成功转换');
})
.on('error',函数(err){
log('发生错误:'+err.message);
})
//保存到文件
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');
setFfmpegPath()
不返回此的实例,如源代码中所示 这意味着你不能把方法链起来

换成

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")

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');
var-ffmpeg=require('fluent-ffmpeg');
//确保为视频文件设置了正确的路径
var proc=new ffmpeg({source:'C:/Users/Jay/Documents/movie/drop.avi',nolog:true})
//设置安装FFmpeg的路径
进程setFfmpegPath(“C:\\Users\\Jay\\Documents\\FFMPEG”)
过程
//设定大小
.withSize('50%”)
//设置fps
.带FPS(24)
//将输出格式设置为强制
.toFormat(“flv”)
//设置事件处理程序
.on('end',function(){
log('文件已成功转换');
})
.on('error',函数(err){
log('发生错误:'+err.message);
})
//保存到文件
.saveToFile('C:/Users/Jay/Documents/movie/drop.flv');

感谢您的回复,这似乎没有改变任何东西,但不幸的是,它抛出了完全相同的错误。非常感谢,再问一个问题,很抱歉,它不再抛出该错误,但它返回了这一行…:发生错误:无法获取可用格式:spawn eNot。有什么想法吗?反斜杠需要用另一个反斜杠来逃避。谢谢你的回答,这似乎没有改变任何事情,但不幸的是,它抛出了完全相同的错误。非常感谢,再问一个问题,对不起,它不再抛出该错误,而是返回此行…:发生错误:无法获取可用格式:spawn enoint。有什么想法吗?反斜杠需要用另一个反斜杠来逃避。谢谢你的回答,这似乎没有改变任何事情,但不幸的是,它抛出了完全相同的错误。非常感谢,再问一个问题,对不起,现在它没有抛出那个错误