PHP 流媒体视频处理程序
我正在尝试实现基于用户访问的视频流解决方案。
我有许多视频流位于连接到服务器的专用网络上(http//192.168.100.101/mpeg4/1/media.amp),并且我想通过网络服务器“代理”该视频流。
我知道如何设置用户访问部分,但如何将视频流代理给用户?
我尝试过类似的方法,但似乎不起作用。
header('Content-type: application/x-rtsp-tunnelled');
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, "http//192.168.100.101/mpeg4/1/media.amp");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
关于最好的方法有什么想法吗?其他流媒体网站是如何做到的?
谢谢 :)
I'm trying to implement a video streaming solution based on user access.
I have many video streams located on a private network connected to the server (http//192.168.100.101/mpeg4/1/media.amp), and I want to "proxy" that video stream through the web server.
I know how to setup the user access part, but how can I proxy the video stream to the user?
I have tried something like this, but it does not seem to work.
header('Content-type: application/x-rtsp-tunnelled');
$ch = curl_init ();
curl_setopt ($ch, CURLOPT_URL, "http//192.168.100.101/mpeg4/1/media.amp");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
echo $output;
curl_close($ch);
Any ideas on the best way to do this? How do other streaming sites do it?
Thanks :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,这很容易做到。无需手动设置这些标头。让服务器自动完成。
这是我为视频流代理编写的工作脚本 -
Yes, its easy to do. No need to set those headers manually. Let the server do it automatically.
Heres a working script which I wrote for a video streaming proxy -
curl_exec() 不是为流输出而设计的。仅当 http 请求完成时才会返回。对于流请求,理论上“从不”,您只会在某处填充内存缓冲区。
检查此答案以获取解决方法: 操作一个 3000 万字符长的字符串
curl_exec() isn't designed for streaming output. It'll return only when the http request is completed. For a streaming request, that would theoretically be "never", and you'll just be filling up a memory buffer somewhere.
Check this answer for workarounds: Manipulate a string that is 30 million characters long
尝试如下页面中的解决方案: Streaming POST通过 PHP cURL 获取数据 我要亲自尝试一下,看看它是否有效,但我想在我分心并忘记这个问题之前我会将其发布到这里:)
Try a solution like in this page: Streaming POST data through PHP cURL I'm gonna try it myself to see if it works, but thought I post this here before I get distracted and forget about this question :)