在 Android 中从字节流播放视频
有没有办法在 Android 中播放字节流视频? 我正在使用特定的通信中间件,因此我不能仅将 http/rtsp 链接传递到 MediaPlayer 对象。
我想知道是否可以使用本地 http/rtsp 链接包装我的流,以便我可以播放流,而不是等到文件下载后才播放。
我的中间件通过 TCP 工作,所以我也认为我可以用 tcp 数据报包装我的 rtsp 数据报,并在删除 TCP 标头后以某种方式在客户端上解释它们。
我真的很惊讶我不能只将字节流传递给 MediaPlayer。 提前致谢。
Is there any way to play a video from a bytes stream in Android?
I'm using an specific communications middleware so I can't just pass the http/rtsp link to the MediaPlayer object.
I was wondering if I can wrap my stream with a local http/rtsp link so I can play the stream instead of waiting until the file is downloaded to play it.
My middleware works over TCP so I've also thought that I can wrap my rtsp datagrams with a tcp datagram and interpret them on the client somehow, after removing the TCP headers.
I'm really surprised that I can't just pass a bytes stream to the MediaPlayer.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Android 中的自定义流媒体并不像我想象的那么容易。我已经成功做到了,但仅限于非常具体的视频。交错性较差的 MPEG4 视频似乎可以流式传输。
我得到的最远的是流式传输此视频:
http://www.pocketjourney。 com/downloads/pj/video/known.3gp
正如 Cipi 回答我的那样,大多数格式不能仅仅打包在字节缓冲区中并将其传递给 MediaPlayer。他们需要一些标头、尾部等。我不确定上述文件中包含哪种格式,但我猜它是 MPEG4。
Custom streaming in Android isn't as easy as I thought. I've managed to do it but only with very specific videos. MPEG4 Videos that are poorly interleaved seem to be streamable.
The farest I've gotten is streaming this video:
http://www.pocketjourney.com/downloads/pj/video/famous.3gp
As Cipi answered me, most formats cannot just be packed in a bytes buffer and pass it to MediaPlayer. They need some headers, tails, etc. I'm not sure which format is contained within the aforementioned file, but I guess it's MPEG4.