音频流服务器 [英] audio streaming server

查看:116
本文介绍了音频流服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是php开发人员,试图开发一个网站来将点播音乐流式传输到用户. 经过大量的搜寻之后,我对应该使用哪种服务器或工具感到困惑?我见过类似WOWZA或SHOUTCAST的影片,但我不知道哪一个最适合我的需求.

I'm a php developer, trying to develop a website to stream on-demand music to the users. After a lot of googling I'm confused about which kind of server or tools should I use? I've seen some like WOWZA or SHOUTCAST, but I don't know which one is the best for my needs.

我想提供高质量的音频文件.所以也许我应该使用320kbps mp3格式或其他格式,但质量要相同.

I want to provide high quality audio files. So maybe I should use 320kbps mp3 format or something else but with the same quality.

我不需要直播.我只需要按需点播音乐文件,以及用户创建自己的播放列表的功能即可.

I don't need live streaming. I just need on-demand streaming of the music files and the ability for the user to create his/her own playlists.

用户不应下载音乐文件.

The user shouldn't be able to download the music files.

推荐答案

Icecast/SHOUTcast不适合您使用.他们采用单个流并将其同时发送到多个连接.它们不是每个用户都可以收听单独内容的按需"服务器.

Icecast/SHOUTcast are not appropriate for your use. They take a single stream and send it to multiple connections simultaneously. They are not "on-demand" servers where each user can listen to separate content.

对于您的用例,您可以在PHP中实现某些功能.您真正要做的就是将媒体文件发送到客户端.您提到要防止客户端下载那些文件……这是不可能的.如果客户端可以播放,则客户端可以保存它,并且无法解决此问题.但是,您可以做一些事情来防止它像链接到文件一样容易.

For your use case, you can implement something in PHP. All you are really doing is sending media files to the client. You mentioned that you wanted to keep the client from downloading those files... this is impossible. If the client can play it, the client can save it, and there is no way around this. However, there are some things you can do that prevent it from being as easy as linking to a file.

不要将音频存储在Web服务器的文档根目录中.所有媒体文件应仅通过PHP脚本提供.这使您可以控制传入的请求.进入readfile().这也使您可以轻松地摆脱简单地从磁盘加载文件(当您开始增长到超过10万个媒体文件时需要).

Don't store your audio in the web server's document root. All media files should be served only from your PHP scripts. This gives you control over the requests coming in. Look into readfile(). This also allows you an easy path to get off of simply loading files from disk (which you will want when you start to grow beyond 100k media files).

用于媒体文件的URL只能使用一次,并且只能用于特定的用户会话ID.即时生成这些URL,但有时间限制.如果您的站点上没有有效会话的某人请求了媒体文件的URL,请不要提供它.如果链接已过期,请不要提供它.这是阻止某人获取URL并将其发布在某些留言板上的原因.只有当前会话有效的网站有效用户才能访问您的媒体文件.

A URL for a media file should only work once, and for a specific user session ID. Generate these URLs on the fly, with a time limit on them. If the URL for the media file is requested by someone who doesn't have a valid session on your site, don't serve it. If the link is expired, don't serve it. This is what prevents someone from getting the URL and posting it on some message board. Only valid users of your site with current valid sessions should be able to get at your media files.

速率限制请求..不允许用户一次下载超出所需数量的文件.如果他们在1秒钟内请求100个文件,请不要提供它们.

Rate-limit requests. Don't allow a user to be able to download more files at a time than is needed. If they request 100 files in 1 second, don't serve them.

实施所有这些概念是我留给您的.这样做取决于您的需求,通常不是在5行代码段中完成的事情.

Implementing all of these concepts is something I leave to you. How you do so depends your needs, and is not something that is typically done in a 5-line snippet of code.

这篇关于音频流服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆