小编Win*_*4l7的帖子

你可以使用webtorrent进行分布式直播视频直播

我想通过webtorrent使用p2p webrtc进行实时视频流.

https://github.com/feross/webtorrent

它可以显然流视频,但它可以作为输入网络摄像头和其他来源?

你会怎么做?

谢谢.

video-streaming webrtc webtorrent

8
推荐指数
1
解决办法
1466
查看次数

如何在浏览器中使用webtorrent?

我在https://github.com/feross/webtorrent#usage中显示的示例有一些问题 我正在尝试在浏览器中使用该代码.所以我首先创建一个名为app.js的文件

app.js

var WebTorrent = require('webtorrent')
var concat = require('concat-stream')

var client = new WebTorrent()
console.log('Hi there');
client.download('magnet:?xt=urn:btih:XXXXXXXX', function (torrent) {
  // Got torrent metadata!
  console.log('Torrent info hash:', torrent.infoHash)

  torrent.files.forEach(function (file) {
    // Get the file data as a Buffer (Uint8Array typed array)
    file.createReadStream().pipe(concat(function (buf) {

      // Append a link to download the file
      var a = document.createElement('a')
      a.download = file.name
      a.href = URL.createObjectURL(new Blob([ buf ]))
      a.textContent = 'download ' + file.name
      document.body.appendChild(a)
    }))
  })
}) …
Run Code Online (Sandbox Code Playgroud)

html javascript browserify webtorrent

6
推荐指数
1
解决办法
6833
查看次数