eneim / toro

Video list auto playback made simple, specially built for RecyclerView

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reduce Buffering of videos

saadbzu opened this issue · comments

First of all thank you for this amazing library!

I face a problem the video take 3,4 second to load into player in recyclerview. I use URL of Video for loading videos in recyclerview. In simple words it take a very long time to buffering and playing video. Please help how i reduce the buffering time and start video fast.

put in cache before start (DownloadVideo to cache file) and verify if have cache for that file.. load from cache ..else load from server

@lucazin Thank you for your help. I'm very thankful to you if you show me the example code.

It should depends on how the video is. How long will it take the Video to load using other players? Do you have an usable link for testing? Video from server relies a lot on the infra (CDN, Device band and network quality).

@eneim I store video in my own server in .mp4 format. Once i try Media Player but its buffering is more than ExoPlayer. Here is an example links of my videos.

  1. http://173.249.13.152:8123/appdata/harisnoor/media/191118061028145.mp4
  2. http://173.249.13.152:8123/appdata/harisnoor/media/191118060352307.mp4
  3. http://173.249.13.152:8123/appdata/harisnoor/media/191118055856634.mp4

I search on google and someone said that use "LoadControl" to set the initial buffering time in "ExoPlayer" but i cannot understand how i use this concept in Toro.

@eneim Please suggest me the possibles solutions, i urgently need the solution. Thank you

Assume that you are using latest version. When constructing new ExoPlayerViewHelper, there is a constructor that allows you to pass in a ExoCreator or a Config. These object allows you to use custom LoadControl and other ExoPlayer’s component. You can have a global ExoCreator or Config object and pass around. Please try that.

Also, mp4 is not the optimized format if you want fast streaming. Investing in HLS or DASH for better performance.

@eneim Here is the code where i use new ExoPlayerViewHelper:

@Override
    public void initialize(@NonNull Container container, @NonNull PlaybackInfo playbackInfo) {
        if (helper == null) {
            //  helper = new ExoPlayerViewHelper(container, this, mediaUri);
            helper = new ExoPlayerViewHelper(this, mediaUri, null, FollowingFragment.config);
        }
        helper.initialize(container, playbackInfo);
        helper.addPlayerEventListener(new EventListener() {
            @Override
            public void onFirstFrameRendered() {

            }

            @Override
            public void onBuffering() {

            }

            @Override
            public void onPlaying() {
                videoThumbnailImage.setVisibility(View.GONE);
            }

            @Override
            public void onPaused() {

            }

            @Override
            public void onCompleted() {

            }
        });


    }

Please help me how i use LoadControl?

@saadbzu

In this line:

helper = new ExoPlayerViewHelper(this, mediaUri, null, FollowingFragment.config);

There is FollowingFragment.config, you can use custom LoadControl with it:

LoadControl myLoadControl = new DefaultLoadControl.Builder()
        // add your custom setup here
        .createDefaultLoadControl();

// If you want to extends/modify current Config
Config modifiedConfig = config.newBuilder()
        .setLoadControl(myLoadControl).build();

// If you want to create new Config
Config newConfig = new Config.Builder(this /* Context */)
        .setLoadControl(myLoadControl).build();

@eneim I set custom LoadControl and the the performance increase a little bit now 2,3 second buffering occur Still the performance not satisfied because 2,3 second are add delay in video play. Here is my server response time,status etc:
-- Time: 380ms
-- Size: 4.18 KB

@eneim can we compress the video with any method?

OR

How i change the video format from .mp4 to HLS or DASH?

If you are serious about delay and want to adopt HLS/DASH, you’d better research yourself using those keywords. It involves not only encoding config, but also CDN and other infrastructures as well. It’s worth investing your time and money in long term.

You should also check your video codec setting (if you own the content). For example VP9 would save you many bytes which results in faster download and first frame delay.

I would like to know whether toro internally handling data source(RTMP,DASH or HLS) selection based on the file type or Should we handle manually? If we need to handle manually, Please provide steps to include it for toro config.

@karanianandkumar toro-exoplayer will internally handle the type for DASH, HLS (RTMP is not officially supported by ExoPlayer, but via an extension I believe).