为icecast服务器开发客户端
我正在为icecast 服务器(www.icecast.org)开发客户端。谁能告诉我,他们用于流式传输内容的格式是什么?
我正在查看他们的页面,但根本没有有关流格式的信息。
然后我检查了 Wireshark 跟踪,由于我了解在 GET 请求的 200 OK 响应中收到的音频数据的格式,它只是一个普通的二进制音频数据,不包含任何元数据,因此与 SHOUTcast 或 HTTP Live Streaming (HLS) 这是相对简单的方法。
是这样吗?有这方面的经验吗?
Wireshark 跟踪片段:
GET /bonton-128.mp3 HTTP/1.1
Host: icecast3.play.cz
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.0 200 OK
Content-Type: audio/mpeg
icy-br:128
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2
icy-br:128
icy-description:Radio Bonton
icy-genre:Pop / Rock
icy-name:Radio Bonton
icy-pub:0
icy-url:http://www.radiobonton.cz
Server: Icecast 2.3.2
Cache-Control: no-cache
Here are then aac or MPEG data
感谢和问候,
STeN
I am developing the client for the icecast server (www.icecast.org). Can anybody tell me, what is the format they are using for streaming the content?
I was looking on their pages, but there is no information about the stream format at all.
I have then checked the Wireshark trace and due to my understanding the format of the audio data I am receiving within the 200 OK response to the GET request it is just a plain binary audio data without any metadata included, so comparing to the SHOUTcast or HTTP Live Streaming (HLS) it is relative simple approach.
Is that right? Any experience with it?
Wireshark trace snippet:
GET /bonton-128.mp3 HTTP/1.1
Host: icecast3.play.cz
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.19.4 (KHTML, like Gecko) Version/5.0.3 Safari/533.19.4
Accept: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-US
Accept-Encoding: gzip, deflate
Connection: keep-alive
HTTP/1.0 200 OK
Content-Type: audio/mpeg
icy-br:128
ice-audio-info: ice-samplerate=44100;ice-bitrate=128;ice-channels=2
icy-br:128
icy-description:Radio Bonton
icy-genre:Pop / Rock
icy-name:Radio Bonton
icy-pub:0
icy-url:http://www.radiobonton.cz
Server: Icecast 2.3.2
Cache-Control: no-cache
Here are then aac or MPEG data
Thanks and regards,
STeN
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就您的目的而言,Icecast 和 SHOUTcast 是等效的。
它们都使用 HTTP 的混用版本。事实上,您可以发出一个简单的 HTTP 请求并使用标准 HTTP 客户端库,它几乎总是可以正常工作。唯一不同的是 SHOUTcast 将在其响应中返回
ICY 200 OK
而不是HTTP 200 OK
。现在,如果您发出请求,正如上面所做的那样,您将获得一个可以直接播放的标准音频流。正如您所指出的,几乎只使用 MP3 和 AAC,但也可以使用其他格式。
如果您想要元数据,您必须告诉服务器您准备好接收它。您必须将此标头放入您的请求中:
一旦您这样做,您将看到响应中返回另一个标头,例如
icy-metaint:8192
,这意味着每 8192 个字节,您将收到一大块元数据。我不会详细介绍,因为这已经有详细记录了。无需重新输入轮子:
拉动使用 PHP 跟踪音频流中的信息
http://www.smackfu.com /stuff/programming/shoutcast.html
但是,如果您确实有疑问,请将其发布到 StackOverflow 上并将其标记为icecast 或shoutcast,我将很乐意为您提供帮助。
For your purposes, Icecast and SHOUTcast are equivalent.
They both use a bastardized version of HTTP. In fact, you can make a simple HTTP request and use standard HTTP client libraries, and it will almost always work just fine. The only thing different is that SHOUTcast will return
ICY 200 OK
instead ofHTTP 200 OK
in its response.Now if you make the request, as you have done above, you get a standard audio stream that you can play directly. As you have pointed out, MP3 and AAC are used almost exclusively, but other formats can be used.
If you want metadata, you have to tell the server you are prepared to receive it. You have to put this header in your request:
Once you do that, you will see another header come back to you in the response, such as
icy-metaint:8192
, which means that every 8192 bytes, you will receive a chunk of metadata.I won't go into further details because this is already well documented. No need to re-type the wheel:
Pulling Track Info From an Audio Stream Using PHP
http://www.smackfu.com/stuff/programming/shoutcast.html
However, if you do have questions as you go, please post them on StackOverflow and tag them as icecast or shoutcast, and I will be happy to assist you.
我最近刚刚完成了一个广播电台项目,他们使用了icecast。我想与您分享广播播放器 以及我用来从centova、icecast 和lastfm 获取信息的一些PHP 包装器。
I have just recently finished a project for radio station, where they used icecast. I want to share you the radio player and some PHP Wrappers that i have used to get information from centova,icecast and lastfm.