4

我是 ExoPlayer 的新手,我目前正准备用它来播放原生 Udp 流(来自法国数字电视:1080p 5-10 mbps 可变比特率)我设法播放一些 udp 流和一些来自http:/的测试视频/jell.yfish.us/在不同的设备上。我使用 HLS 和 Udp Streaming 对 UDP 进行了一些不同的视频解码测试:

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 不正式支持 Udpstreaming,但 UdpDataSource 类似乎运行良好。

在所有测试之后,我注意到像法国 DTT 这样的可变比特率的视频无法正确解码,但是对于像 Jell yfish 这样的恒定比特率视频,解码过程是完美的。

有一些编码改进可以使 VBR 视频正确解码?提前谢谢你:)对不起我的英语不好:)

4

1 回答 1

0
    Uri uri = Uri.parse("udp://@239.192.2.2:1234");

我认为 UDP 不是一种协议——它是一种传输方式(如 TCP)。您也不能使用 tcp://host:port/ URL。

或者它有效吗?

于 2018-05-09T08:14:50.117 回答