通过 http 将视频流式传输到 Windows Media Player

发布于 2024-09-26 09:10:59 字数 1479 浏览 7 评论 0原文

尝试从 servlet 将视频流式传输到 Windows Media Player(渐进式下载样式)。流媒体工作正常,但我有一些奇怪的行为,我想排除这不是由我的实现中的问题引起的。

当使用 WMP 从 servlet 打开 url 时,WMP 将对同一资源总共执行 4 个 http-get 请求,但每次的标头略有不同。前 3 个请求的连接似乎在请求(包括标头)发送后立即关闭。第四个请求保持连接,我实际上可以传递响应标头和文件内容。

尝试使用wireshark来观看前三个请求。所有 4 个请求都发送相同的响应开始,前 3 个请求在关闭之前成功发送了响应标头和部分文件内容。 (不知道它是否相关,但必须启用“支持从支持 IP TSO 的硬件捕获数据包”,wireshark 才能正确解析流,否则包含 http 响应的第一个数据包将被视为格式错误。)

4请求标头如下:

GET /basic/test.mpg HTTP/1.1
Accept: */*
User-Agent: Windows-Media-Player/12.0.7600.16415
Accept-Encoding: gzip, deflate
Host: 192.168.1.34
Connection: Keep-Alive

GET /basic/test.mpg HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: getIfoFileURI.dlna.org
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
GetContentFeatures.DLNA.ORG: 1
Host: 192.168.1.34

GET /basic/test.mpg HTTP/1.1
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
Icy-Metadata: 1
Accept-Encoding: gzip, deflate
Host: 192.168.1.34
Connection: Keep-Alive

GET /basic/test.mpg HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: getIfoFileURI.dlna.org
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
GetContentFeatures.DLNA.ORG: 1
Host: 192.168.1.34

响应标头:

HTTP/1.1 200 OK
Content-Type: video/mpeg
Content-Length: 130549760
ETag: TEST1286565215430
ContentFeatures.DLNA.ORG: DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_OP=00
Server: Jetty(6.1.x)

Trying to stream video to windows media player from a servlet (progressive download style). The streaming works, but I have some weird behavior, which I would like to rule out is not caused by a problem in my implementation.

When using WMP to open an url from the servlet, WMP will perform a total of 4 http-get requests for the same resource, but with slightly different headers each time. The connection for the first 3 requests seems to be closed as soon as the request (including headers) have been sent. The fourth request remains connected, and I can actually deliver response headers and the file content.

Have tried using wireshark to watch the first three requests. Identical starts of responses are sent for all 4 requests, and the first 3 requests managed to send the response headers, and some part of the file content before being closed. (Don't know if its relevant, but have to enable "Support packet-capture from IP TSO-enabled hardware" for wireshark to correctly parse the stream, otherwise the first packet containing the http-response is seen as malformed.)

The 4 request headers below here:

GET /basic/test.mpg HTTP/1.1
Accept: */*
User-Agent: Windows-Media-Player/12.0.7600.16415
Accept-Encoding: gzip, deflate
Host: 192.168.1.34
Connection: Keep-Alive

GET /basic/test.mpg HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: getIfoFileURI.dlna.org
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
GetContentFeatures.DLNA.ORG: 1
Host: 192.168.1.34

GET /basic/test.mpg HTTP/1.1
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
Icy-Metadata: 1
Accept-Encoding: gzip, deflate
Host: 192.168.1.34
Connection: Keep-Alive

GET /basic/test.mpg HTTP/1.1
Cache-Control: no-cache
Connection: Keep-Alive
Pragma: getIfoFileURI.dlna.org
Accept: */*
User-Agent: NSPlayer/12.00.7600.16385 WMFSDK/12.00.7600.16385
GetContentFeatures.DLNA.ORG: 1
Host: 192.168.1.34

Response headers:

HTTP/1.1 200 OK
Content-Type: video/mpeg
Content-Length: 130549760
ETag: TEST1286565215430
ContentFeatures.DLNA.ORG: DLNA.ORG_PN=MPEG_PS_PAL;DLNA.ORG_OP=00
Server: Jetty(6.1.x)

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

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

发布评论

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

评论(1

趴在窗边数星星i 2024-10-03 09:10:59

一旦发送请求(包括标头),前 3 个请求的连接似乎就会关闭。

“似乎是”?在继续之前,我会找出某种方法或方法。如果在设置响应标头后结束连接,则可能是玩家期望出现非常特定的标头。示例可以包括 Range:Cache-Control:

The connection for the first 3 requests seems to be closed as soon as the request (including headers) have been sent.

"Seems to be"? I would find out for certain one way or the before proceeding. If it is ending the connection after the response headers are set, it could be that the player was expecting a very specific header to be present. Examples could include Range: or Cache-Control:.

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