Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClippedMediaSource ends sooner than expected when using REPEAT_MODE_ALL or ConcatenatingMediaSource #4583

Closed
MateusZitelli opened this issue Jul 26, 2018 · 5 comments
Assignees
Labels

Comments

@MateusZitelli
Copy link

MateusZitelli commented Jul 26, 2018

Issue description

Clipped video playback ends sooner than expected when repeat mode is Player.REPEAT_MODE_ALL or when it is combined with other clips using ConcatenatingMediaSource.

Reproduction steps

Setup a simple ExoPlayer instance:

val trackSelector = DefaultTrackSelector()
val renderersFactory = DefaultRenderersFactory(context)
val loadControl = DefaultLoadControl()
val player = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl)
player.repeatMode = Player.REPEAT_MODE_ALL
val extractorMediaSourceFactory = ExtractorMediaSource.Factory(dataSourceFactory)

val startMs = 300
val endMs = 1000
val path = "/sdcard/Movies/probe-video.mp4"

val videoUri = Uri.parse(path)
val extractorMediaSource = extractorMediaSourceFactory.createMediaSource(videoUri)
val clippingMediaSource = ClippingMediaSource(
    extractorMediaSource,
    startMs * 1000,
    endMs * 1000)

val concatenatingMediaSource = ConcatenatingMediaSource()
concatenatingMediaSource.addMediaSources(listOf(mediaSource, mediaSource))

Logging player.currentPosition

Observable
    .interval(10, TimeUnit.MILLISECONDS)
    .observeOn(AndroidSchedulers.mainThread())
    .subscribe { Log.d("PlayerPresenter", "${player.currentPosition}") }
With Player.REPEAT_MODE_OFF or player.prepare(clippingMediaSource)

PlayerPresenter: 0
PlayerPresenter: 14
PlayerPresenter: 14
PlayerPresenter: 14
PlayerPresenter: 14
...
PlayerPresenter: 686
PlayerPresenter: 706
PlayerPresenter: 706

With Player.REPEAT_MODE_ALL or player.prepare(concatenatingMediaSource)

PlayerPresenter: 14
PlayerPresenter: 14
...
PlayerPresenter: 400
PlayerPresenter: 400
PlayerPresenter: 400
PlayerPresenter: -300
PlayerPresenter: -300
PlayerPresenter: -300
PlayerPresenter: -300

Link to test content

I was able to reproduce this issue with any local mp4.

Version of ExoPlayer being used

2.8.2

Device(s) and version(s) of Android being used

  • Essential phone w/ Android 8.1
  • Samsung Note 8 w/ Android 7.1
    However it doesn't seem to be a device specific issue.
@MateusZitelli MateusZitelli changed the title Clipped video playback ends sooner than expected when using REPEAT_MODE_ALL ClippedMediaSource ends sooner than expected when using REPEAT_MODE_ALL or ConcatednatingMediaSource Jul 26, 2018
@MateusZitelli MateusZitelli changed the title ClippedMediaSource ends sooner than expected when using REPEAT_MODE_ALL or ConcatednatingMediaSource ClippedMediaSource ends sooner than expected when using REPEAT_MODE_ALL or ConcatenatingMediaSource Jul 26, 2018
@tonihei tonihei self-assigned this Jul 27, 2018
@tonihei tonihei added the bug label Jul 27, 2018
@tonihei
Copy link
Collaborator

tonihei commented Jul 27, 2018

Thanks for reporting! We'll provide a fix for that.

@MateusZitelli
Copy link
Author

Great! Is there any time estimate for that fix? Also, if you could provide some guidance I am happy to try to solve it. Thanks for your attention.

@MateusZitelli
Copy link
Author

Debugging ExoPlayer it seems like the next media period preparation finishes before the actual period playback. Then the next period playback starts when the preparation finishes, skipping the last ms of the first period. However, I am not sure how to proceed to fix it.

@andrewlewis
Copy link
Collaborator

The fix should be pushed to the development branch soon.

ojw28 pushed a commit that referenced this issue Aug 1, 2018
Period transitions with non-zero start position happen too early as the
playing period is advanced as soon as the renderer offset is reached not
taking into account that the start position needs to be added to that.

Issue:#4583

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=206310328
@MateusZitelli
Copy link
Author

The commit did the job, thanks for the great work!

@google google locked and limited conversation to collaborators Dec 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants