使用 Android 将实时视频流传输到服务器 [英] Transfer real-time video stream to server using Android

查看:123
本文介绍了使用 Android 将实时视频流传输到服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们必须使用 Android Camera 捕捉实时视频,并将它们发送到服务器,然后其他用户才能通过浏览器或其他方式读取它们.

我在 SO 上进行了 Google 搜索和搜索,还有一些关于视频流应用的示例,例如:

1 Android-eye:,而将您的视频转换为 FLV 会让您头疼.(在许多情况下,例如,如果以后您想将流传送到 Android 设备.)

所以我建议建立像 spyDroid 之类的东西.

2. 流媒体服务器

有像 Wowza Server 这样的工具可以获取源流并将其放在服务器的输出上以供其他客户端使用.我猜VLC 也可以做到这一点,通过 File-->Stream 菜单,然后把来自基于 spyDroid 的应用程序的 RTSP 视频流地址.但是我有没亲自试过.

此外,实现自己的流媒体服务器也不是一项艰巨的工作.

我给你举个例子:

对于 HLS 服务器的实现,您只需要三件事:

  1. 视频文件,分段为 10 秒的 MPEG2 块.(即 .ts 文件)
  2. 块的 m3U8 播放列表.
  3. 具有简单 Web 服务的 Web 服务器,可通过 HTTP 将播放列表传送到客户端(PC、Android、iPhone,主要是所有设备).然后客户端将查找播放列表文件并根据他们的时间要求适当的块.因为几乎所有播放器都内置了 HLS 支持.

3. 客户端

根据我们的评论,我建议您可能想要更深入地了解 Android Video Streaming.

要完成这么大的项目,您需要进行更多研究.例如,您应该能够区分 RTP 和 RTSP,并了解它们之间的关系.

此处阅读我的回答,了解最先进的视频流,请随时要求更多.

希望你对未来的旅程有一个大局,

祝你好运,玩得开心

We have to capture the real-time video using Android Camera, and send them to the server, then other users would read them through the browser or something else.

I have Googled and searched at SO, and there are some examples about video stream app like:

1 Android-eye: https://github.com/Teaonly/android-eye

2 Spydroid-ipcamera:https://code.google.com/p/spydroid-ipcamera/

However it seems that they have different environments, most of the apps will start an HTTP server for stream requests, then the client will visit the page through the local network and see the video.

Then the video stream source and the server are both the device like this:

But we need the internet support like this:

So I wonder if there are any alternative ideas.

解决方案

I can see you have designed the three stages correctly, in your second diagram.

So what you need is to determine how to choose among these protocols and how to interface them. No one can give you a complete solution but having completed an enterprise project on Android Video Streaming I will try to straighten your sight towards your goal.

There are three parts in your picture, I'll elaborate from left to right:

1. Android Streamer Device

Based on my experience, I can say Android does well sending Camera streams over RTP, due to native support, while converting your video to FLV gives you headache. (In many cases, e.g. if later you want to deliver the stream on to the Android devices.)

So I would suggest building up on something like spyDroid.

2. Streaming Server

There are tools like Wowza Server which can get a source stream and put it on the output of the server for other clients. I guess VLC can do this too, via File-->Stream menu, an then putting the RTSP video stream address from your spyDroid based app. But I have not tried it personally.

Also it is not a hard work to implement your own streamer server.

I'll give you an example:

For Implementation of an HLS server, you just need three things:

  1. Video files, segmented into 10 second MPEG2 chunks. (i.e. .ts files)
  2. An m3U8 playlist of the chunks.
  3. A Web Server with a simple WebService that deliver the playlist to the Clients (PC, Android, iPhone, mostly every device) over HTTP. The clients will then look up the playlist file and ask for the appropriate chunks on their according timing. Because nearly all players have built-in HLS support.

3. The Client-Side

Based on our comments, I suggest you might want to dig deeper into Android Video Streaming.

To complete a project this big, you need much more research. For example you should be able to distinguish RTP from RTSP and understand how they are related to each other.

Read my answer here to get a sense of state-of-the-art Video Streaming and please feel free to ask for more.

Hope you got the big picture of the journey ahead,

Good Luck and Have Fun

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

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