Android Exoplayer 2 UDP解码问题
我是ExoPlayer的新手,目前正准备使用它来播放本地Udp流(来自法国数字电视:1080p5-10Mbps可变比特率) 我设法在不同的设备上播放一些udp流和一些测试视频。 我用HLS和Udp流做了一些不同的视频解码测试,Udp代码如下:Android Exoplayer 2 UDP解码问题,android,video,udp,streaming,exoplayer2.x,Android,Video,Udp,Streaming,Exoplayer2.x,我是ExoPlayer的新手,目前正准备使用它来播放本地Udp流(来自法国数字电视:1080p5-10Mbps可变比特率) 我设法在不同的设备上播放一些udp流和一些测试视频。 我用HLS和Udp流做了一些不同的视频解码测试,Udp代码如下: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.myactiv
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myactivity);
sufaceview = (SurfaceView) findViewById(R.id.surfaceView2);
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl(
new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE),
15000, 60000, 2500, 6000);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);
Uri uri =
Uri.parse
("udp://@239.192.2.2:1234");
final DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "teveolauncher"), bandwidthMeterA);
extractorsFactory = new DefaultExtractorsFactory();
DataSource.Factory udsf = new UdpDataSource.Factory() {
@Override
public DataSource createDataSource() {
return new UdpDataSource(null, 3000, 100000);
}
};
ExtractorsFactory tsExtractorFactory = new ExtractorsFactory() {
@Override
public Extractor[] createExtractors() {
return new TsExtractor[]{new TsExtractor(MODE_SINGLE_PMT,
new TimestampAdjuster(0), new DefaultTsPayloadReaderFactory())};
}
};
MediaSource videoSource = new ExtractorMediaSource
(uri, udsf, tsExtractorFactory, null, null);
player.setVideoSurfaceView(sufaceview);
player.prepare(videoSource);
player.setPlayWhenReady(true);
}
对于HLS,我只需更改MediaSource和datasourceFactory:
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "teveolauncher"), bandwidthMeterA);
MediaSource videoSource = new HlsMediaSource
(uri, dataSourceFactory, null, null);
我知道ExoPlayer并不正式支持UDPStream,但UdpDataSource类似乎工作得很好
在所有的测试之后,我注意到像french DTT这样的可变比特率视频无法正确解码,但是像Jell yfish这样的恒比特率视频的解码过程是完美的
有一些编码改进,使VBR视频解码正确?
提前感谢:)
对不起,我的英语不好:)
我认为UDP不是一种协议——它是一种传输协议(如TCP)。你不能使用tcp://host:port/ URL也可以
或者它能起作用吗
Uri uri = Uri.parse("udp://@239.192.2.2:1234");