是否可以使用代理网址提供视频内容?

问题描述 投票:0回答:1

假设我们在http://www.example.com/video.mp4上有一个视频

是否可以使用另一个无法追踪的链接名称来嵌入此视频?

<video src ='http://www.proxyserver.com/video.mp4'/>

喜欢Proxied链接?

要清楚:我不想下载视频。

node.js html5 video proxy
1个回答
1
投票

有可能,您应该使用http librairie创建一个带有节点的http服务器,当您在该服务器上获得请求时,您只需要使用带有流支持的请求模块在http://www.example.com/video.mp4上发出真实请求,那么您可以只使用res.pipe(videoStream)和它应该工作。

例子(没有经过测试但是这样的东西当然可以使用express / koa / etc而不是http)

const http = require('http')

http.createServer(function (req, res) {
  if (req.path === '/video.mp4') {
    const stream = request.get('http://www.example.com/video.mp4')

    res.end(stream)
  }
}).listen(3000)
© www.soinside.com 2019 - 2024. All rights reserved.