Android的视频流的例子 [英] Android video streaming example

查看:346
本文介绍了Android的视频流的例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想实现视频流在我的项目。那么,有没有工作的任何教程?画被存储在服务器端。所以,使用URL抓取视频,并发挥它在Android上。我尝试了一些例子,但我得到的错误,对不起,该视频无法播放。我想用MP4。

解决方案

我有同样的问题,但终于让我找到的方式。

下面是穿行:

1 - 您的计算机(服务器)上安装VLC,去媒体 - >视频流(Ctrl + S键)

2 - 选择一个文件流或者,如果你想流你的摄像头或...点击捕​​获设备选项卡,然后执行配置,最后点击流按钮。

3在这里,你应该做的流媒体服务器的配置,只要进入选项选项卡,并粘贴以下命令:

<$p$p><$c$c>:sout=#trans$c$c{v$c$cc=mp4v,vb=400,fps=10,width=176,height=144,a$c$cc=mp4a,ab=32,channels=1,samplerate=22050}:rtp{sdp=rtsp://YOURCOMPUTER_SERVER_IP_ADDR:5544/}

注:替换 YOURCOMPUTER_SERVER_IP_ADDR 与您的计算机的IP地址或运行VLC任何服务器...

注:您可以看到,视频codeC是MP4V这是支持的Andr​​oid

4-去Eclipse和创造媒体回放时一个新的项目。 创建VideoView对象,并在OnCreate()函数写一些code是这样的:

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

mVideoView.setVideoPath(rtsp://形式YOURCOMPUTER_SERVER_IP_ADDR:5544 /);
mVideoView.setMediaController(新的MediaController(本));
 

5运行在设备上的apk文件(不是模拟器,我没有检查),并等待播放启动。请考虑缓冲过程将持续约10秒......

问:任何人都知道如何减少缓冲时间和播放视频,几乎住

I want to implement video streaming in my project. So, is there any tutorial that works? Videos are stored at server side. So, to fetch video using URL and play it on Android. I tried some examples, but I got error, "Sorry, this video can not be played". I am trying to use MP4.

解决方案

I had the same problem but finally I found the way.

Here is the walk through:

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 paste 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...

Question: Anybody know how to reduce buffering time and play video almost live ?

这篇关于Android的视频流的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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