使用 PHP 和 curl 获取远程 FLV

发布于 2024-08-13 20:53:09 字数 208 浏览 2 评论 0原文

我想知道是否可以获取远程 flv 文件并使用 PHP 和 exec 函数对其进行“流式传输”。我的环境中有“curl”,所以我想要类似的东西:

exec ('curl http://myhosts.com/myflv.flv', $out);
print $out;

问题是 $out 作为数组返回;我想输出curl返回的“原始”流。

I want to know if it's possible to get a remote flv file and have it 'stream' using PHP and exec function. I have 'curl' in my environnement so i want something like :

exec ('curl http://myhosts.com/myflv.flv', $out);
print $out;

Problem is that $out is returned as an array; i want to output the 'raw' stream returned by curl.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

聆听风音 2024-08-20 20:53:09

您应该能够使用 fpassthru() ,尽管它将用户重定向到正确的 URL 可能会更好。

$fp = fopen('http://myhosts.com/myflv.flv', 'rb');
fpassthru($fp);

或者重定向:

header('Location: http://myhosts.com/myflv.flv');

想一想,您甚至应该能够使用 readfile( )

readfile('http://myhosts.com/myflv.flv');

无论如何,如果您可以简单地重定向用户,那就这样做。这效率更高。

You should be able to use fpassthru() for that, although it would probably be better to just redirect the user to the proper URL instead.

$fp = fopen('http://myhosts.com/myflv.flv', 'rb');
fpassthru($fp);

Or redirect:

header('Location: http://myhosts.com/myflv.flv');

Come to think of it, you should even be able to use readfile()

readfile('http://myhosts.com/myflv.flv');

At any rate, if you can simply redirect the user, do that. It's way more efficient.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文