安卓中的RTSP客户端[英] RTSP Client in Android

本文是小编为大家收集整理的关于安卓中的RTSP客户端的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

可能已经提出了相同的问题,但我没有找到任何可供我使用的解决方案.

我正在尝试在Android中播放RTSP流,服务器是达尔文流式服务器.目前,我尝试了VideoView和MediaPlayer,两者始终在使用3G时始终正常工作,但是当我使用WiFi时出现问题,特别是当我在我的工作场所使用WiFi时,以及Logcat中的错误:

PlayerDriver( 31): buffering (0)

我已经oogled并猜测原因可能是WiFi热点在防火墙后面,UDP端口被阻止,并且opencore媒体框架只支持UDP的RTP.如果我错了,请纠正我.

然后,这里是我的问题,如果我无法更改防火墙情况,我如何解决它.如果不可能使用构建视频/MediaPlayer,那么如何编写自己的RTSP客户端.

任何建议都将得到理解:)

提前感谢!

博尔顿

推荐答案

我不认为你可以做到很多......我的想法:

制作一个应用程序将在与darvin相同的局域网中启动,然后它将获得darvin的rtp流,它超过了UDP(在LAN中),然后通过TCP传输到WAN,因此您可以访问它.您可以在C#中轻松编写该应用程序......它将完美地工作.或者如果您有一些Linux发行版,您可以编写一个复杂的Bash脚本,该脚本将使用NC进行同样的...

所以这基本上是这个想法: 在此处输入图像描述

其他推荐答案

使用MediaPlayer建议使用RTSP.但是,正如您所说,问题仍然存在WiFi防火墙,在这种情况下,您必须启用端口或配置需要.我认为这没有解决方案,因为问题是网络而不是您的代码.所以球不在你的球场.

其他推荐答案

它在Android中的相当简单而有趣的任务.

只是按照说明操作.

1-在计算机上安装VLC(服务器)并转到媒体 - >流(Ctrl + S) 2-选择要流的文件或者要将网络摄像头传输或...单击"Capture Device"选项卡并执行配置,然后单击"流"按钮. 3-此处您应该执行Streaming Server配置,只需转到"选项"选项卡,并浏览以下命令:

:sout =#转码{vcodec = mp4v,vb = 400,fps = 10,宽度= 176,高度= 144,acodec = mp4a,ab = 32,通道= 1,samplerve = 22050}:rtp {sdp = RTSP://yourcomputer_server_ip_addr:5544/}

注意:使用计算机IP地址或运行VLC的任何服务器替换您的COMPUTER_SERVER_IP_ADDR ...

注意:您可以看到,视频编解码器是Android支持的MP4V.

4-转到Eclipse并为Media PlayBak创建一个新项目.创建VideoView对象和onCreate()函数写一些代码如下:

mVideoView = (VideoView) findViewById(R.id.surface_view);

mVideoView.setVideoPath("rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/");
mVideoView.setMediaController(new MediaController(this));

5-在设备上运行APK(不是模拟器,我没有检查)并等待播放开始.请考虑缓冲过程需要大约10秒...

本文地址:https://www.itbaoku.cn/post/102719.html

问题描述

The same question might have been asked but I didn't find any solutions available for me.

I'm trying to play RTSP stream in android and the server is Darwin streaming server. For now I’ve tried VideoView and MediaPlayer, both of which always work fine when I use 3G but have problems when I use Wifi sometimes, specifically when I use Wifi at my workplace, and the error in LogCat:

PlayerDriver( 31): buffering (0)

I have googled around and guess the reason maybe the Wifi hotspot is behind the firewall and the UDP port is blocked, and the Opencore media framework only supports RTP over UDP. Correct me if I am wrong.

Then, here is my question, how can I solve it if i cannot change the firewall situation. If using the build-in VideoView/MediaPlayer is not possible, then how to write my own rtsp client.

Any suggestion will be appreciated:)

Thanks in advance!

Bolton

推荐答案

I don't think that you can do much with this... Heres my idea:

Make an app that will be started in the same LAN as Darvin, then it will get Darvin's RTP stream which goes over UDP (in LAN) and then transmit that over TCP to WAN, so you can access it. You can easily write that app in C#... and it will work perfectly. Or if you have some Linux distro, you can write a complex Bash script that will use NC to do the same...

So this is basically the idea: enter image description here

其他推荐答案

Using the MediaPlayer is recommended way to go with RTSP. but as you said that the problem persist with the WiFi firewall, in such case you have to have enable the ports or configure the needful. I think there is no solution for this as the problem is with network not your code. So the ball is not in your court.

其他推荐答案

Its quite easy and interesting task in android.

Just Follow the instructions.

1- Install VLC on your computer (SERVER) and go to Media->Streaming (Ctrl+S) 2- select a file to stream or if you want to stream your webcam or... click on "Capture Device" tab and do the configuration and finally click on "Stream" button. 3- here you should do the streaming server configuration, just go to "Option" tab and past the following command:

:sout=#transcode{vcodec=mp4v,vb=400,fps=10,width=176,height=144,acodec=mp4a,ab=32,channels =1,samplerate=22050}:rtp{sdp=rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/}

NOTE: replace YOURCOMPUTER_SERVER_IP_ADDR with your computer IP address or any server which is running VLC...

NOTE: You can see, the video codec is MP4V which is supported by android.

4- go to eclipse and create a new project for media playbak. create a VideoView object and in the OnCreate() function write some code like this:

mVideoView = (VideoView) findViewById(R.id.surface_view);

mVideoView.setVideoPath("rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/");
mVideoView.setMediaController(new MediaController(this));

5- run the apk on the device (not simulator, i did not check it) and wait for the playback to be started. please consider the buffering process will take about 10 seconds...