Я работаю с Live HLS -потоковой передачей с помощью URL .m3u8. Я наблюдаю за значительную разницу в задержке между двумя игроками:
Моя установка:
Theoplayer (Web): достигает живой латентности от 2,5 до 3 секунд.
exoplayer (Android): постоянно показывает более 4 секунд латентности. /> Подробности: < /strong>
Тот же URL .m3u8 используется для обоих игроков. Пробое: < /strong>
настроить LiveConfiguration на MediaItem для использования SetLiveOffSetoverRidems () (например, 2000 мс). < /P>
Пониженные размеры буфера с использованием DefaultLoadControl.Builder. < /P>
ниже мой код для Setup Exo Player и Play Video: < /p>
ниже мой код для Setup exo и воспроизводить видео: < /p>
ниже код для Setup exo и воспроизводится.private void initPlayerView() {
cronetDataSourceFactory.setUserAgent("Android");
cronetDataSourceFactory.setConnectionTimeoutMs(15_000); // 10s connection timeout
cronetDataSourceFactory.setReadTimeoutMs(15_000); // 10s read timeout
cronetDataSourceFactory.setResetTimeoutOnRedirects(true); // Reset timeout on redirects
DefaultDataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(this, cronetDataSourceFactory);
HlsMediaSource.Factory hlsMediaSourceFactory = new HlsMediaSource.Factory(dataSourceFactory)
.setAllowChunklessPreparation(true)
.setUseSessionKeys(true)
.setTimestampAdjusterInitializationTimeoutMs(10_000)
.setLoadErrorHandlingPolicy(
new DefaultLoadErrorHandlingPolicy(3) // Minimum loadable retry count
);
AudioAttributes audioAttributes = new AudioAttributes.Builder()
.setUsage(C.USAGE_MEDIA)
.setContentType(C.AUDIO_CONTENT_TYPE_MOVIE)
.build();
RenderersFactory renderersFactory = new DefaultRenderersFactory(this)
.setEnableDecoderFallback(true);
LoadControl loadControl = new DefaultLoadControl.Builder()
// .setBackBuffer(20_000, true)
.setBufferDurationsMs(
1000, // minBufferMs: Minimum buffer before playback resumes after re-buffering
3000, // maxBufferMs: Maximum buffer to avoid loading too far ahead
500, // bufferForPlaybackMs: Buffer needed to start playback
500 // bufferForPlaybackAfterRebufferMs: Buffer needed after re-buffering
)
.setPrioritizeTimeOverSizeThresholds(true) // Prioritize time-based buffering
.build();
trackSelector = new DefaultTrackSelector(this);
LivePlaybackSpeedControl liveSpeedControl = new DefaultLivePlaybackSpeedControl.Builder()
.setMinUpdateIntervalMs(1000) // Check live offset more frequently
.setTargetLiveOffsetIncrementOnRebufferMs(100) // Small adjustment after re-buffering
.setMaxLiveOffsetErrorMsForUnitSpeed(500) // Tolerate up to 500 ms deviation before speeding up/slowing down
.setFallbackMaxPlaybackSpeed(1.04f)
.setFallbackMinPlaybackSpeed(.98f)
.build();
exoPlayer = new ExoPlayer.Builder(this)
.setUsePlatformDiagnostics(false)
.setMediaSourceFactory(hlsMediaSourceFactory)
.setLivePlaybackSpeedControl(liveSpeedControl)
.setRenderersFactory(renderersFactory)
.setTrackSelector(trackSelector)
.setHandleAudioBecomingNoisy(true)
.setLoadControl(loadControl)
.setAudioAttributes(audioAttributes, true)
.build();
exoPlayer.setWakeMode(C.WAKE_MODE_NETWORK);
exoPlayer.addListener(playerListener);
PlayerControlView controlView = playerView.findViewById(androidx.media3.ui.R.id.exo_controller);
mFullScreenIcon = controlView.findViewById(R.id.exo_fullscreen_icon);
mFullScreenIcon.setOnClickListener(v -> {
if (!isBackStagePlaying) {
if (!startLandscape) {
startFullScreenVideoActivity();
startLandscape = true;
mFullScreenIcon.setImageResource(R.drawable.ic_fullscreen_skrink);
} else {
onBackPressed();
startLandscape = false;
mFullScreenIcon.setImageResource(R.drawable.ic_fullscreen_expand);
}
}
});
}
< /code>
private void playVideo() {
if (!fromBackstageToLive) {
loadProgress.setVisibility(VISIBLE);
}
isBuffer = true;
String hlsUrl = getVideo(video);
if (exoPlayer == null) {
initPlayerView();
}
// trackSelector.setParameters(trackSelector.buildUponParameters()
// .setMaxVideoSize(Integer.MAX_VALUE, Integer.MAX_VALUE)
// .setMinVideoSize(Integer.MIN_VALUE, Integer.MIN_VALUE)
// );
playerView.setPlayer(exoPlayer);
playerView.setControllerShowTimeoutMs(3_000);
exoPlayer.setPlaybackParameters(new PlaybackParameters(1.0f, 1.0f));
exoPlayer.setMediaItem(
new MediaItem.Builder()
.setUri(hlsUrl)
.setLiveConfiguration(
new MediaItem.LiveConfiguration.Builder()
.setMinOffsetMs(500) // Minimum allowable offset
.setMaxOffsetMs(5000) // Maximum allowable offset before forcing a jump
.setTargetOffsetMs(2000) // Allow playback as close as 1 second to the live edge
.build()
)
.setMimeType(MimeTypes.APPLICATION_M3U8)
.build()
);
playerView.setResizeMode(video.getTypeIndex() == BroadcastVideo.LIVE && video.getStart_voting().equalsIgnoreCase(Constants.Voting_status_pending) ? RESIZE_MODE_FILL : RESIZE_MODE_FIT);
exoPlayer.prepare();
exoPlayer.play();
exoPlayer.seekToDefaultPosition();
handler.postDelayed(latencyRunnable, 5_000);
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... theoplayer
Высокая задержка с живым потоком M3U8 в экзоплайере по сравнению с Theoplayer ⇐ Android
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение
-
-
Высокая задержка с живым потоком M3U8 в экзоплайере по сравнению с Theoplayer
Anonymous » » в форуме Android - 0 Ответы
- 5 Просмотры
-
Последнее сообщение Anonymous
-