HTTP上的H.264 / MP2T ExoPlayer

时间:2014-11-03 08:25:04

标签: h.264 mpeg2-ts hls exoplayer

我正在使用此代码在ExoPlayer上使用HLS播放简单的MPEG-TS:

LoadControl loadControl = new DefaultLoadControl(new BufferPool(BUFFER_SEGMENT_SIZE));
String userAgent = getUserAgent(mContext);
Log.d(TAG, userAgent);
HlsMasterPlaylist manifest = newSimpleMasterPlaylist("http://192.168.1.1/rtp/239.0.0.77:8208");
DataSource dataSource = new HttpDataSource(userAgent, null, null);
HlsChunkSource chunkSource = new HlsChunkSource(dataSource, manifest);
HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true, 2);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 100, mainHandler, null, 50);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
ExoPlayer exoPlayer = ExoPlayer.Factory.newInstance(RENDERER_COUNT);
exoPlayer.prepare(videoRenderer,audioRenderer);
// Pass the surface to the video renderer.
exoPlayer.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
exoPlayer.setPlayWhenReady(true);

使用另一种方法:

private HlsMasterPlaylist newSimpleMasterPlaylist(String mediaPlaylistUrl) {
return new HlsMasterPlaylist(Uri.parse(""),
Collections.singletonList(new Variant(mediaPlaylistUrl, 0)));
}

它不起作用。我明白了:

11-03 09:56:10.785: D/dalvikvm(10907): GC_FOR_ALLOC freed 3K, 8% free 4422K/4780K, paused 33ms, total 34ms
11-03 09:56:14.005: D/dalvikvm(10907): GC_FOR_ALLOC freed 5K, 7% free 5383K/5732K, paused 40ms, total 40ms
11-03 09:56:18.085: D/dalvikvm(10907): GC_FOR_ALLOC freed 11K, 6% free 6663K/7024K, paused 37ms, total 37ms
11-03 09:56:25.075: D/dalvikvm(10907): GC_FOR_ALLOC freed 14K, 4% free 8392K/8724K, paused 41ms, total 41ms
11-03 09:56:33.115: D/dalvikvm(10907): GC_FOR_ALLOC freed 21K, 4% free 10697K/11036K, paused 37ms, total 37ms
11-03 09:56:44.155: D/dalvikvm(10907): GC_FOR_ALLOC freed 28K, 3% free 13707K/14096K, paused 50ms, total 51ms
11-03 09:56:58.485: D/dalvikvm(10907): GC_FOR_ALLOC freed 40K, 3% free 17741K/18108K, paused 34ms, total 34ms

我认为使用单个MPEG2TS文件,我可以使用此代码创建单个媒体播放列表,它可以工作,但我不知道如何执行此操作。

由于

1 个答案:

答案 0 :(得分:0)

目前我还没有在ExoPlayer中看到MPEG-TS(或MP2T)支持。

是什么让你相信这种方法会起作用?

注意:什么是" HlsChunkSource"?我在标准的ExoPlayer源代码中找不到对它的引用。