在Android中播放RTSP流

发布于 12-05 05:54 字数 1255 浏览 4 评论 0原文

我正在尝试在 Android 设备上播放视频流。不幸的是,我在 MediaPlayer/VideoView 上仍然遇到同样的问题。我已经搜索了几天,但仍然没有找到任何可行的解决方案。 出于测试目的,我使用 API 演示(API 演示/媒体/MediaPlayer/播放流视频)中的 MediaPlayer 应用程序。 这是播放流的代码片段

mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);

当我尝试播放流时,我从 logcat 获取此信息 http://pastebin.com/5Uib5CH5

这是 ffserver 流式传输视频的配置

Port 8090
BindAddress 0.0.0.0

RTSPPort 7654
RTSPBindAddress 0.0.0.0

MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000

CustomLog -
NoDaemon
<Feed feed1.ffm>

File /tmp/feed1.ffm
FileMaxSize 5M

Launch ffmpeg -i mmsh://tempserv.cam/vid1

ACL allow 127.0.0.1

</Feed>

<Stream rat1.mpg>
Feed feed1.ffm
Format rtp
NoAudio
VideoBitRate 56k
VideoBufferSize 40
VideoFrameRate 12
VideoSize 176x144
VideoGopSize 12
VideoCodec libx264
AVPresetVideo baseline
</Stream>

如果有人可以建议我如何修复,或者至少指出一个错误,我将不胜感激。

I'm trying to play video stream on Android device. Unfortunatelly I still get the same problem with MediaPlayer/VideoView. I'm searching for a few days, but still haven't found any working solution.
For test purposes I'm using MediaPlayer app from API Demos (API Demos/Media/MediaPlayer/Play Streaming Video).
Here is code snippet for playing stream

mMediaPlayer = new MediaPlayer();
mMediaPlayer.setDataSource(path);
mMediaPlayer.setDisplay(holder);
mMediaPlayer.prepare();
mMediaPlayer.setOnBufferingUpdateListener(this);
mMediaPlayer.setOnCompletionListener(this);
mMediaPlayer.setOnPreparedListener(this);
mMediaPlayer.setOnVideoSizeChangedListener(this);

When I try to play stream I get this info from logcat
http://pastebin.com/5Uib5CH5

This is configuration of ffserver streaming the video

Port 8090
BindAddress 0.0.0.0

RTSPPort 7654
RTSPBindAddress 0.0.0.0

MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000

CustomLog -
NoDaemon
<Feed feed1.ffm>

File /tmp/feed1.ffm
FileMaxSize 5M

Launch ffmpeg -i mmsh://tempserv.cam/vid1

ACL allow 127.0.0.1

</Feed>

<Stream rat1.mpg>
Feed feed1.ffm
Format rtp
NoAudio
VideoBitRate 56k
VideoBufferSize 40
VideoFrameRate 12
VideoSize 176x144
VideoGopSize 12
VideoCodec libx264
AVPresetVideo baseline
</Stream>

If anyone can advise me how to fix it, or at least indicate an mistake, I will be grateful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

画尸师2024-12-12 05:54:29

我找到了如何运行适合 Android 设备的流媒体的解决方案。这是我为任何其他有类似问题的人提供的 ffserver 配置。

Port 8090
BindAddress 0.0.0.0
RTSPPort 7654
RTSPBindAddress 0.0.0.0

MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000

CustomLog -
NoDaemon

<Feed feed1.ffm>

File /tmp/feed1.ffm
FileMaxSize 5M

Launch ffmpeg -i mmsh://tempserv.cam/vid1

ACL allow 127.0.0.1
</Feed>

<Stream rat1.mpg>

Feed feed1.ffm
Format rtp
NoAudio

VideoBitRate 56k
VideoBufferSize 40
VideoFrameRate 12
VideoSize 176x144
VideoGopSize 12
VideoCodec h263

AVOptionVideo flags +global_header

</Stream>

I've found solution how to run streaming suitable for Android device. This is my ffserver configuration for any other person with the similar problem.

Port 8090
BindAddress 0.0.0.0
RTSPPort 7654
RTSPBindAddress 0.0.0.0

MaxHTTPConnections 2000
MaxClients 1000
MaxBandwidth 10000

CustomLog -
NoDaemon

<Feed feed1.ffm>

File /tmp/feed1.ffm
FileMaxSize 5M

Launch ffmpeg -i mmsh://tempserv.cam/vid1

ACL allow 127.0.0.1
</Feed>

<Stream rat1.mpg>

Feed feed1.ffm
Format rtp
NoAudio

VideoBitRate 56k
VideoBufferSize 40
VideoFrameRate 12
VideoSize 176x144
VideoGopSize 12
VideoCodec h263

AVOptionVideo flags +global_header

</Stream>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文