Android 媒体播放器 - 从网络流播放
我正在尝试制作一个 Android 媒体播放器,它应该播放网络流中的媒体。我知道它可以播放通过 RTSP 或 HTTP 传输的媒体,但我的情况有所不同。
我没有任何媒体流服务器,如果我打算使用一个,那么我将不得不修改它。
我想做的是将 Android 相机捕获的视频流式传输到服务器,对视频进行一些修改(例如更改颜色或应用一些效果等)并将其流式传输回手机。因此,通常我的屏幕分为两部分,一部分用于上行视频,另一部分用于显示下行视频。
现在我正在做的是将视频捕获到 SD 卡上,同时我正在读取它并将其传输到网络上。在 Web 部件上,我正在捕获视频(将其保存在文件中 [我也可以在服务器上播放视频])并将其发送回手机。在手机上,我能够接收它,但我无法弄清楚如何将此流转换为正确的格式,以便我可以在 VideoPlayer
中播放它。
我还发现 MediaPlayer
提供了一些从 FileDescriptor
播放视频的方法,因此我可以从套接字创建一个 FileDescriptor
并将其传递给 媒体播放器
?这个方法行得通吗?是否可以在没有 RTSP 或 HTTP 的情况下做到这一点?
I am trying to make an android media player which should play the media from network stream. I know it can play media that is streamed on RTSP or HTTP but my case is different.
I am not having any media streaming server and if I intend to use one, then I will have to modify it.
What I am trying to do is to stream the video that is being captured from android camera to the server, do little bit of modification in the video (like change color or apply some effect, etc) and stream it back to the phone. So typically my screen is divided in 2 parts, one is for upstreaming and other shows down streamed video.
Now what I am doing is capturing the video on sdcard and at the same time I am reading it and streaming it to the web. On web part, I am capturing the video (saving it in file [I am also able to play the video on the server]) and sending it back to the phone. On phone I am able to receive it but I am not able to figure out how to convert this stream to the proper format so that I can play it in VideoPlayer
.
I also found that MediaPlayer
provides some method to play the video from FileDescriptor
so can I create a FileDescriptor
from the socket and pass it to MediaPlayer
? Will this method work? Is it possible to do it without RTSP or HTTP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用这个
try to use this