现场直播专题 [英] Live Streaming Topic

查看:148
本文介绍了现场直播专题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这可能是人谁是intrested在livestreaming 您的设备相当intresting题目 Web服务器。 (主要的Andr​​oid / Java的) 我终于找到了如何从我的设备的摄像头livestream到我的网络服务器(网站)的方式。在WiFi网络,这大约需要。 1帧/秒显示一个WiFi网络上,它也EDGE / 3G网络。在这个话题/问题,我想讨论的新技术,改进想法livestreaming,因为我将与你分享我(codeS是pciated太AP $ P $。)

This could be quite an intresting topic for people who are intrested in livestreaming from your device to a webserver. (Primary Android/Java) I have finally found a way on how to livestream from my device's camera to my webserver (website). On a wifi network it takes approx. 1 frame/ second to show on a wifi network, It also works on EDGE/3G network. In this topic/question, I want to discuss new techniques, improvements, ideas about livestreaming as I will share mine with yours (codes are appreciated too.)

我的code反复发生的快照使用setOneShot previewCallback()到previewFrame调用摄像头preVIEW()。该框架已提供的YUV格式,以便raw2jpg()将其转换成32位ARGB为JPEG EN codeR。 NV21是为YUV平面格式

My code repeatedly takes a snapshot from the camera preview using setOneShotPreviewCallback() to call onPreviewFrame(). The frame is delivered in YUV format so raw2jpg() converts it into 32 bit ARGB for the jpeg encoder. NV21 is a YUV planar format.

Getpicture中()被调用,通过该应用程序,并且产生的JPEG数据的私人字节数组mCurrentFrame在图像并返回该阵列。

getPicture() is called, by the application, and produces the jpeg data for the image in the private byte array mCurrentFrame and returns that array.

在此之后,则ByteArray mCurrentFrame被Base64En codeD并传送到我的网络服务器的HTTP POST方法一起使用Base64的字符串值和自己的ID code所以人们将不能同时发送另一映像。在Web服务器,它再次推得去codeD插入文件test.jpg放在。 PHP和JavaScript是在web服务器上运行。 PHP获取POST方法和JavaScript重新加载图像中的每个750秒。这基本上是如何工作的。

After this, the byteArray mCurrentFrame gets Base64Encoded and send to my webserver in a HTTP POST method together with the string value of Base64 and a own ID code so people won't be able to also send another image to it. At the webserver, it gets decoded again and putted into the file test.jpg. PHP and Javascript is running on the webserver. PHP gets the POST method and JavaScript reloads the image every 750 seconds. This is basically how it works.

现在我非常intrested在你的想法,改进和其他的东西你想添加/问。 下面是我的一些问题:

Now I am very intrested in your ideas, improvements and other things you would like to add/ask. Here are some of my questions:

1)什么是实时流与音频的最好方法是什么?视频信号录制或我的方法+录音?

1) What would be the best method for live streaming WITH audio? Video Recording OR my method + Audio recording?

2)你如何接近录像流?

2) How would you approach video record streaming?

3)你将如何流音频的网络服务器? (主要目标)(在Java,PHP和JavaScript)

3) How would you stream audio to the webserver? (Main goal) (With Java, PHP and JavaScript)

4)我还打算典型的流媒体直播feautures添加到我,例如:当一个著名的人出现,你可以有展现自己的名字的能力,而你是现场直播,还是刚刚从你的SD目录添加图片到你的livestream。你是否还去code,并覆盖在图像,或者将图像中的livestream以某种方式?

4) I am also planning to add typical live streaming feautures to i, e.g. when a famous person appears, you could have the ability to show his name while you are live streaming, or just add an image from your sd directory to your livestream. Would you also decode it and overlay the image, or put the image in your livestream in some way?

这题目是primarly的问题,所以请这可能是对某些人某些很大的帮助在这里。所以我加了50(活泉!)代表一个赏金吧。

This topic is primarly for questions, so please this could be some great help for some people out here. Therefore I added a bounty of 50 (woot!) rep to it.

真诚的, XverhelstX

Sincerely, XverhelstX

推荐答案

这让我感到HTTP发布可能不是一个好办法做到实时流视频到你的服务器。其他人都在玩直播和他们使用的插座,以现场直播的视频流和音频流到他们的服务器。

It strikes me that http posting is probably not a good way to do live streaming of video to your server. Other people have been playing with live streaming and they've used a socket to broadcast live video streams and audio streams to their servers.

我认为这是有趣的 - 这里有一个链接

I thought this was fascinating -- here's a link.

<一个href="http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system">http://www.mattakis.com/blog/kisg/20090708/broadcasting-video-with-android-without-writing-to-the-file-system

不过,这家伙还公布了部分code样品 -

But the guy also posted a partial code sample -

String hostname = "your.host.name";
int port = 1234;

Socket socket = new Socket(InetAddress.getByName(hostname), port);

ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);

MediaRecorder recorder = new MediaRecorder();

// Additional MediaRecorder setup (output format ... etc.) omitted

recorder.setOutputFile(pfd.getFileDescriptor());

recorder.prepare();

recorder.start();

最酷的一部分,我不知道是ParcelFileDescriptor - 它创建于Android的文件系统,实际上是一个管道,一个套接字文件 - 所以任何被写入文件被播出了通过网络向远程服务器。套接字是正确的方式去这样做这样的事情太多,因为他们让你连续发送数据,直到录制完成,而不必一遍遍重新发送头。

The cool part I didn't know about is the ParcelFileDescriptor - which creates a file on the android filesystem that is actually a pipe to a socket - so anything that gets written to the file gets broadcast out over the web to a remote server. Sockets are the right way to go about doing this sort of thing too because they allow you to continuously send data until your recording is complete without having to re-send headers over and over.

我觉得是酷的这一技术,他是从字面上采取从MediaRecorder输出(这将是一间codeD的视频流),并抽它通过套接字来他的服务器。然后,他可以简单地救出来的是未来在通过套接字的数据。没有一帧一帧,不做任何处理(Android SDK中不公开EN codeRS SDK中的非常好,他们是pretty的性能降低)。

What I think is cool about this technique is that he's literally taking the output from MediaRecorder (which is going to be an encoded video stream) and pumping it over a socket to his server. Then he can simply save out the data that's coming in over the socket. No frame by frame, no processing (Android SDK doesn't expose the encoders in the SDK very well and they're pretty performance intensive).

人报告说,它的工作原理,但我没有测试。不管怎么说,希望这是有帮助的。

People report that it works, but I haven't tested. Anyway, hope this is helpful.

这篇关于现场直播专题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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