Exoplayer slow seekTo() update

See original GitHub issue

Dear ExoPlayer Devs, I would like to use ExoPlayer to seek through a local video via the seekTo(long position) method. The video is not actually played, but instead being scrubbed through like this.

What I’ve done so far has basically achieved this function, however the performance is not very great. The returned frames are quite slow to update and basically get stuck after a while. I suspect this is because the touch event ACTION_MOVE has to wait for the video to buffer, so I try to disable it via mExoPlayer = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 0, 0);

However I can not figure out what to do with BUFFER_SEGMENT_SIZE and BUFFER_SEGMENT_COUNT as from my research and experiment, setting these too low and the video can’t be played at all, setting these too high and it just make my problem worse.

I would like to ask is there a way to completely remove the buffer so that exoPlayer can just instantly return the frame at seekTo(long position) and if not, is there any way to improve the performance?

I would like to add these severe stuttering or stuck only happen with videos captured by the Samsung Galaxy s6 running Android 5.1.1. With videos captured by Nexus 5 running 6.0.1 or low resolution videos, the problem is not as severe. (I’m sorry since currently I only has those two devices to test. In case I can get a hold of more devices, I’ll update the results.)

Below is my code snippet using ExoPlayer version 1.5.6:

    private static final int RENDERER_COUNT = 1;
    private static final int BUFFER_SEGMENT_SIZE = 64 * 1024;
    private static final int BUFFER_SEGMENT_COUNT = 64; // default 256
.....

        // 1. Instantiate the player. RENDERER_COUNT is the number of renderers to be used.
        // In this case it’s 1 since we will only use a video renderer. If you need audio and video renderers it should be 2.
        mExoPlayer = ExoPlayer.Factory.newInstance(RENDERER_COUNT, 0, 0); //disable the buffer and rebuffer for better performance

        // 2. Construct renderer.
        Uri uri = Uri.parse(mVideoPath);
        Allocator allocator = new DefaultAllocator(BUFFER_SEGMENT_SIZE);
        String userAgent = Util.getUserAgent(this, "Android Demo");
        DataSource dataSource = new DefaultUriDataSource(this, null, userAgent);
        ExtractorSampleSource sampleSource = new ExtractorSampleSource(uri, dataSource, allocator, BUFFER_SEGMENT_COUNT * BUFFER_SEGMENT_SIZE);
        MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(
                this, sampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);

        // 3. Inject the renderer through prepare.
        mExoPlayer.prepare(videoRenderer);

        // 4. Pass the surface to the video renderer.
        mExoPlayer.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, holder.getSurface());

        // 5. Start playback.
        mExoPlayer.seekTo(currentVideoPosition);

Thanks you very much for your time,

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

7reactions
saketcommented, Apr 3, 2017

So I was comparing scrubbing this video on my Pixel using ExoPlayer and on an iPad using Narwhal. I don’t know what stack is Narwhal using, but scrubbing is fairly smooth and seeking is instantaneous for buffered parts of the video including rewind, but ExoPlayer was taking half a second for the same task.

I was also using this library to cache the video so the Uri supplied to ExoPlayer was a locally cached File.

@andrewlewis does this make sense?

0reactions
nitinicommented, Jun 8, 2017

Hi,

I too am curious if ExoPlayer supports smooth / fast scrubbing of video. I’m struggling to describe what I’m looking for but on iOS when I record a video with my camera and then play it back, I can use my finger to swipe through the video fast or slow and the scrubbing is smooth. On Android however (Nexus 5X) I’m finding that this same behavior is very choppy.

Are there video players on Android that can do what I am describing on iOS? Thanks for any info!

Read more comments on GitHub >

github_iconTop Results From Across the Web

seekTo restarting playback on exoplayer - Stack Overflow
While trying to call seekTo function of exoplayer instance the playback is getting reset and playing from start after buffering live audio ...
Read more >
Anyone using ExoPlayer - specifically having seek issues
If I attempt to seek forward using the seek bar of the MediaPlayer it can be a bit slow finding the new position...
Read more >
Troubleshooting - ExoPlayer
Why is seeking in my video slow? Why do some MPEG-TS files fail to play? Why do some MP4/FMP4 files play incorrectly? Why...
Read more >
Deep Understanding of Seek - Taku Semba - Medium
With ExoPlayer, seek operation can be done by player.seekTo(positionMs). In this post, I will look into how seeking can be archived inside ExoPlayer....
Read more >
Exoplayer Tutorial: How to Stream Videos Securely on Android?
ExoPlayer is an open-source media player for Android maintained by Google ... of new features as they become available by updating your app....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found