ExoPlayer无法播放Adobe实时流编码器播放的音频/视频流(RTMP)

时间:2019-02-24 08:04:25

标签: android rtmp live-streaming exoplayer2.x

我正在使用Adobe Live Stream Encoder在服务器端流传输RTMP现场音​​频。 在我的Android客户端应用中,带有RTMP Extension的ExoPlayer无法播放并导致RtmpIOException,但是我可以在VLC或MPC上播放。

我用其他RTMP链接测试了我的android应用,没关系。

我还在手机中安装的其他视频播放器(MxPlayer,Vlc)中也使用了此网址,没关系。

这是android中播放视频的代码:

BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();     

TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory();
TrackSelector trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);

//Create the player
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
playerView.setPlayer(player);
MediaSource videoSource = null;

Uri uri = Uri.parse("rtmp://172.18.49.6/live/11");

dataSourceFactory = new RtmpDataSourceFactory();
videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
                .createMediaSource(uri);

player.prepare(videoSource);
player.setPlayWhenReady(true);

这是一个例外:

E/ExoPlayerImplInternal: Source error.
net.butterflytv.rtmp_client.RtmpClient$RtmpIOException
    at net.butterflytv.rtmp_client.RtmpClient.open(RtmpClient.java:56)
    at com.google.android.exoplayer2.ext.rtmp.RtmpDataSource.open(RtmpDataSource.java:60)
    at com.google.android.exoplayer2.upstream.StatsDataSource.open(StatsDataSource.java:83)
    at com.google.android.exoplayer2.source.ExtractorMediaPeriod$ExtractingLoadable.load(ExtractorMediaPeriod.java:885)
    at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:381)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
    at java.lang.Thread.run(Thread.java:818)

1 个答案:

答案 0 :(得分:0)

我也遇到了类似的问题,请尝试在RTMP URL上进行修改:

Before:
Uri uri = Uri.parse("rtmp://172.18.49.6/live/11");

After:
Uri uri = Uri.parse("rtmp://172.18.49.6/live/11 live=1");