npm install --save fluent-ffmpeg //使用js编码的用户,可以忽略下条命令 npm install --save @types/fluent-ffmpeg
const ffmpegPath = "./dist/ffmpegProgram/bin/ffmpeg.exe";
const ffprobePath = "./dist/ffmpegProgram/bin/ffprobe.exe";
const flvtoolPath = "./dist/ffmpegProgram/bin/ffplay.exe";
export function startPushVideo():void{
getCommands().then((commands:ffmpegPaths[])=>{
for(let key in commands){
let command = commands[key];
//设置输入流地址
let ffCommand = ffmpeg(command.inputPath)
//设置输出流地址
.output(command.outputPath)
//因需要打包客户端软件,故而将ffmpeg打包进软件中
//需设置各应用程序的对应路径
//若仅在本机使用,可以跳过该步骤
//设置环境变量,添加 PATH 即可
.setFfmpegPath(ffmpegPath)
.setFfprobePath(ffprobePath)
.setFlvtoolPath(flvtoolPath)
//为保证灵活性,非必须参数采用配置文件读取模式
.size(command.size);
for(let key in command.args){
ffCommand.outputOption(command.args[key]);
}
ffCommand.on("start",(commandLine)=>{
//commandLine 为实际上调用的命令行命令,拼接逻辑为
//您的ffmpeg所在路径 -i inputOptions 您的拉流协议和路径 outputOptions 推送流协议和地址
//ffmpeg -i "rtsp://yourPullUrl" -f flv -r 25 -s 640x480 -an "rtmp://yourPushUrl"
console.log('[' + showTime() + '] Vedio is Pushing !');
console.log('[' + showTime() + '] Spawned Ffmpeg with command !');
console.log('[' + showTime() + '] Command: ' + commandLine);
})
.on('error', function(err, stdout, stderr) {
console.log('error: ' + err.message);
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
})
.on('end', function() {
console.log('[' + showTime() + '] Vedio Pushing is Finished !');
})
.run();
}
},(error)=>{
console.log('error: ' + error);
})
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有