详解nodejs 使用ffmpeg获取电脑摄像头数据进行rtsp推流
2018-01-23 17:55
351 查看
nodejs 使用fluent-ffmpeg获取电脑摄像头数据进行推流
安装fluent-ffmpegnpm install fluent-ffmpeg
设置ffmpeg路径
FFMPEG_PATH 加入环境变量中 或者使用Ffmpeg.setFfmpegPath(path)
使用案例
var outputh = 'rtsp://' + 'ip' + ':' + 'port' + '/' + textname; var ffmpegPath = "./ffmpeg_bin/ffmpeg.exe"; var ffmpeg = require('fluent-ffmpeg'); command = new ffmpeg('video=HD USB Camera') .setFfmpegPath(ffmpegPath) .inputOptions('-f dshow') .size('800x600') .on('start', function(commandLine) { console.log("start push......." + commandLine); console.log("start command......." + command); }) .on('end', function() { console.log("storp push........") stopPush(); }) .on('error', function(err, stdout, stderr) { console.log('error:' + err.message); console.log('stdout:' + stdout); console.log('stderr:' + stderr); stopPush(); }) .addOptions([ // '-preset veryfast', '-rtsp_transport tcp', '-f rtsp' ]) .pipe(outputh, { end: true });`
停止推流
根据说明使用kill函数。但是我测试的无效,会报错 所以使用不优雅的方式直接使用child_process进行杀掉进程 var child_process = require('child_process'); var chile = child_process.exec('"taskkill" /F /IM ffmpeg.exe* /T', function(error, stdout, stderr) { if (error) { console.error(`exec error: ${error}`); return; } console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); });
相关文章推荐
- 使用Transact-SQL进行数据导入导出方法详解
- 使用Transact-SQL进行数据导入导出方法详解
- 使用FFMPEG对流数据进行解码
- 使用Transact-SQL进行数据导入导出方法详解
- 使用Transact-SQL进行数据导入导出方法详解
- 使用Transact-SQL进行数据导入导出方法详解
- python数据库操作常用功能使用详解(创建表/插入数据/获取数据)
- 1个比较简单的使用java反射机制获取前台数据进行数据封装的例子
- 使用ffmpeg获取一帧摄像头数据
- Swift - 使用NSURL进行数据的提交和获取(POST与GET)
- 使用Transact-SQL进行数据导入导出方法详解[转]
- 无废话Android之android下junit测试框架配置、保存文件到手机内存、android下文件访问的权限、保存文件到SD卡、获取SD卡大小、使用SharedPreferences进行数据存储、使用Pull解析器操作XML文件、android下操作sqlite数据库和事务(2)
- 使用R进行数据可视化套路之-多重散点图、连接Mysql获取数据
- 使用Transact-SQL进行数据导入导出方法详解
- 使用Mono Cecil 动态获取运行时数据 (Atribute形式 进行注入 用于写Log) [此文报考 xxx is declared in another module and needs to be imported的解决方法]-摘自网络
- 使用Transact-SQL进行数据导入导出方法详解
- 使用smartUpload组件进行文件上传以及获取文本数据
- 如何使用DropDownList进行数据绑定并获取值
- 使用jQuery解析JSON数据(jquery在前台对从后台获取到的json数据进行解析,并进行显示)