node.js fluent-ffmpeg 桌面推流
1,安装fluent-ffmpeg,npm install fluent-ffmpeg
2,推流代码:
//stream.js
const ffmpeg = require('fluent-ffmpeg');
const rtmpUrl = "rtmp://localhost:1935/live/desktop";
//ffmpeg -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv -pix_fmt yuv420p rtmp://localhost:1935/live/desktop
// 配置 ffmpeg
const command = ffmpeg()
.input('desktop') // 捕获桌面
.inputFormat('gdigrab') //windows
//.inputOptions([
// '-framerate 30',
// '-video_size 1920x1080'
//])
.outputOptions([
'-c:v libx264',
'-preset ultrafast',
'-tune zerolatency',
'-f flv',
'-pix_fmt yuv420p'
])
.output(rtmpUrl);
// 开始推流
command.run();
console.log('开始推流到:', rtmpUrl);
原文地址:https://blog.csdn.net/daqinzl/article/details/143981281
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!