index.js 711 B

12345678910111213141516171819202122232425262728
  1. const ffmpeg = require("fluent-ffmpeg");
  2. const path = require('path')
  3. const ffmpegPath = path.join(__dirname, './ffmpeg-4.4-essentials_build/bin/ffmpeg.exe')
  4. command = ffmpeg()
  5. .setFfmpegPath(ffmpegPath)
  6. .input('@device_pnp_')
  7. .inputFormat("dshow")
  8. .addOptions([
  9. "-vcodec libx264",
  10. "-preset ultrafast",
  11. "-acodec aac",
  12. "-pix_fmt yuv422p"
  13. ])
  14. .format("flv")
  15. .output('rtmp://127.0.0.1:49600/live', {
  16. end: true
  17. })
  18. .on("start", function (commandLine) {
  19. console.log('开始推流');
  20. })
  21. .on("error", function (err, stdout, stderr) {
  22. console.log('推流失败',err);
  23. })
  24. .on("end", function () {
  25. });
  26. command.run();