LiveConfiguration and ClippingConfiguration have no effect. Live RTSP playback falls behind and crashes with OutOfMemoryException
@microkatz is already working on this.
Since Dec 4, 2023.
- Dominant language
- Java
- Stars
- 3k
- Forks
- 955
- Avg merge
- 12d 14h
- Merged PRs (30d)
- 2
Description
Version
Media3 1.2.0
More version details
No response
Devices that reproduce the issue
Emulator running Android 13 API 33 x86_64
MicroTouch IC-215P-AA2 running Android 10
Devices that do not reproduce the issue
No response
Reproducible in the demo app?
Not tested
Reproduction steps
I'm trying to play a live RTSP stream, but if the network experiences temporary slowness, ExoPlayer falls behind the live edge and never catches up, even though I've set a target offset. If the lag continues, this causes ExoPlayer to build up a buffer of increasing size, eventually crashing the app from OutOfMemoryException after an hour or so. I only want to play the stream as close as possible to the live edge, immediately jumping to the latest if it falls behind. I'm currently trying to pass a ClippingConfiguration to prevent it from building up a buffer, but it doesn't appear to have any effect either. What am I missing here?
Steps to reproduce:
- In Emulator, start a player.
- Open
Extended Controls->Cellularand changeNetwork typefromFulltoHSDPAto simulate lag. - Wait a couple of seconds and change it back to
Full. - Observe that playback has fallen behind and won't catch up.
// Keep playback at the live edge to avoid falling behind and running out of memory for the buffer.
private val liveConfiguration = LiveConfiguration.Builder()
.setTargetOffsetMs(100)
.setMinOffsetMs(100)
.setMaxOffsetMs(1000)
.setMinPlaybackSpeed(0.8f)
.setMaxPlaybackSpeed(1.2f)
.build()
// Prevent storing all video that we've already seen to avoid out-of-memory error.
private val clippingConfiguration = ClippingConfiguration.Builder()
.setRelativeToLiveWindow(true)
.setStartPositionMs(0)
.setEndPositionMs(1000)
.build()
val mediaItem = MediaItem.Builder()
.setUri(newUrl)
.setLiveConfiguration(liveConfiguration)
.setClippingConfiguration(clippingConfiguration)
.build()
val mediaSource = RtspMediaSource.Factory().createMediaSource(mediaItem)
val player: ExoPlayer = ExoPlayer.Builder(ctx).build()
player.setMediaSource(mediaSource)
player.prepare()
player.play()
I've logged some properties from the player that show that it's buffered about 5 seconds ahead of the current position. However, it's maintaining that offset and failing to catch up like I would expect from the LiveConfiguration:
isLive: true
playbackState: 3
bufferedPercentage: 0
bufferedPosition: 1475943
contentBufferedPosition: 1475943
contentPosition: 1471056
contentDuration: -9223372036854775807
currentLiveOffset: -9223372036854775807
duration: -9223372036854775807
currentPosition: 1471056
timeline.window.isLive: true
timeline.window.isDynamic: false
timeline.window.windowStartTimeMs: -9223372036854775807
timeline.window.currentUnixTimeMs: 1701209043405
timeline.window.defaultPositionMs: 0
Expected result
Desired behavior:
- Plays at live edge all the time
- If it encounters lag, it jumps to the live edge when it recovers.
- Prevent building up buffer and crashing the app.
Actual result
Actual behavior
- Playback falls behind and never catches up.
- Builds up buffer and crashes the app.
Media
Not applicable
Bug Report
- You will email the zip file produced by
adb bugreportto android-media-github@google.com after filing this issue.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.