有时在埃克斯层中非常缓慢的视频缓冲?

发布于 2025-01-27 08:19:40 字数 1597 浏览 5 评论 0 原文

我不知道为什么,但是有时 exoplayer 非常缓慢地缓冲我的视频。我的服务器响应正确,互联网也很快,但有时 exoplayer 缓慢缓冲我的视频不到1秒钟。每1-2秒钟演奏一次后,它总是缓冲一次。

        int MIN_BUFFER_DURATION = 3000;
        int MAX_BUFFER_DURATION = 8000;
        int MIN_PLAYBACK_RESUME_BUFFER = 1500;
        int MIN_PLAYBACK_START_BUFFER = 500;
        LoadControl loadControl = new DefaultLoadControl.Builder()
                .setAllocator(new DefaultAllocator(true, 16))
                .setBufferDurationsMs(MIN_BUFFER_DURATION,
                        MAX_BUFFER_DURATION,
                        MIN_PLAYBACK_START_BUFFER,
                        MIN_PLAYBACK_RESUME_BUFFER)
                .setTargetBufferBytes(-1)
                .setPrioritizeTimeOverSizeThresholds(true).createDefaultLoadControl();
        TrackSelector trackSelector = new DefaultTrackSelector();
        simpleExoPlayer = new ExoPlayer.Builder(this).setTrackSelector(trackSelector).setLoadControl(loadControl).build();
        binding.exoPlayerView.setPlayer(simpleExoPlayer);
        mediaItem = MediaItem.fromUri(getVid);
        simpleExoPlayer.addMediaItem(mediaItem);
        simpleExoPlayer.prepare();
        simpleExoPlayer.play();

我正在测试我的视频和 Chrome浏览器播放器。 chrome浏览器玩家播放我的视频4倍,我的应用程序 exoplayer`?而且我在同一时间播放相同的视频。有人还在埃法尔git中问了这个问题,但没有得到一个很好的答案或结果请参阅他们的问题“ noreferrer”> exoplayer github essue github 同样的问题引起了我!

有人知道为什么会发生这种情况吗?您的答案对我有帮助。

I don't know why, but sometimes Exoplayer buffers my video very slowly. My server is responding properly and the internet is also fast but sometimes Exoplayer buffers my video slowly for less than 1 second. And it buffering always after every 1-2 seconds on playing.

        int MIN_BUFFER_DURATION = 3000;
        int MAX_BUFFER_DURATION = 8000;
        int MIN_PLAYBACK_RESUME_BUFFER = 1500;
        int MIN_PLAYBACK_START_BUFFER = 500;
        LoadControl loadControl = new DefaultLoadControl.Builder()
                .setAllocator(new DefaultAllocator(true, 16))
                .setBufferDurationsMs(MIN_BUFFER_DURATION,
                        MAX_BUFFER_DURATION,
                        MIN_PLAYBACK_START_BUFFER,
                        MIN_PLAYBACK_RESUME_BUFFER)
                .setTargetBufferBytes(-1)
                .setPrioritizeTimeOverSizeThresholds(true).createDefaultLoadControl();
        TrackSelector trackSelector = new DefaultTrackSelector();
        simpleExoPlayer = new ExoPlayer.Builder(this).setTrackSelector(trackSelector).setLoadControl(loadControl).build();
        binding.exoPlayerView.setPlayer(simpleExoPlayer);
        mediaItem = MediaItem.fromUri(getVid);
        simpleExoPlayer.addMediaItem(mediaItem);
        simpleExoPlayer.prepare();
        simpleExoPlayer.play();

I'm testing my video in my Exoplayer and Chrome Browser player. Chrome browserplayer plays my video 4X faster than my appExoplayer`? And I'm playing the same video and the same time. Someone also asked this question in exoplayer git but not got a good answer or result see their question exoplayer issue github this same issue causing me!

Does anyone know why this happens? Your answer will helpful for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

心舞飞扬 2025-02-03 08:19:40
  1. 确保您使用的是最新版本的Exoplayer。在撰写本文时,是2.10.4。

  2. 尝试增加loadControl中的缓冲持续时间值:

int MIN_BUFFER_DURATION = 3000; // 3 seconds 
int MAX_BUFFER_DURATION = 8000; // 8 seconds 
int MIN_PLAYBACK_RESUME_BUFFER = 1500; // 1.5 seconds 
int MIN_PLAYBACK_START_BUFFER = 500; // 0.5 seconds 
LoadControl loadControl = new DefaultLoadControl.Builder() 
   .setAllocator(new DefaultAllocator(true, 16)) 
   .setBufferDurationsMs(
        MIN_BUFFER_DURATION, 
        MAX_BUFFER_DURATION, 
        MIN_PLAYBACK_START_BUFFER, 
        MIN_PLAYBACK_RESUME_BUFFER) 
   .setTargetBufferBytes(-1) 
   .setPrioritizeTimeOverSizeThresholds(true)
   .createDefaultLoadControl()
  1. 尝试使用其他负载孔。例如,您可以使用较小的目标缓冲区(例如,视频比特率的25%)使用DefaultloadControl:
int TARGET_BUFFER_BYTES = (int) (0.25 * videoBitrate); // 25% of the video bitrate in bytes 
LoadControl loadControl = new DefaultLoadControl(
    new DefaultAllocator(true, 16), 
    TARGET_BUFFER_BYTES, 
    DEFAULT_MIN_REBUFFER_MS,
    DEFAULT_MAX_LOADING_MS,
    DEFAULT_MIN_ELAPSED_MS_BEFORE_STOPPING,
    false
); 
  1. 尝试使用其他分配器。例如,您可以使用较大的一个:
int allocatorSize = 2 * 1024 * 1024; // 2MB 
Allocator allocator = new DefaultAllocator(true, allocatorSize); 
LoadControl loadControl = new DefaultLoadControl(
    allocator,
    DEFAULT_TARGET_BUFFER_BYTES, 
    DEFAULT_MIN_REBUFFER_MS,
    DEFAULT_MAX_LOADING_MS,
    DEFAULT_MIN_ELAPSED_MS_BEFORE_STOPPING,
    false
); 
  1. Make sure you are using the latest version of Exoplayer. As of this writing, that is 2.10.4.

  2. Try increasing the buffer duration values in your LoadControl:

int MIN_BUFFER_DURATION = 3000; // 3 seconds 
int MAX_BUFFER_DURATION = 8000; // 8 seconds 
int MIN_PLAYBACK_RESUME_BUFFER = 1500; // 1.5 seconds 
int MIN_PLAYBACK_START_BUFFER = 500; // 0.5 seconds 
LoadControl loadControl = new DefaultLoadControl.Builder() 
   .setAllocator(new DefaultAllocator(true, 16)) 
   .setBufferDurationsMs(
        MIN_BUFFER_DURATION, 
        MAX_BUFFER_DURATION, 
        MIN_PLAYBACK_START_BUFFER, 
        MIN_PLAYBACK_RESUME_BUFFER) 
   .setTargetBufferBytes(-1) 
   .setPrioritizeTimeOverSizeThresholds(true)
   .createDefaultLoadControl()
  1. Try using a different LoadControl. For example, you could use DefaultLoadControl with a smaller target buffer (e.g. 25% of the video bitrate):
int TARGET_BUFFER_BYTES = (int) (0.25 * videoBitrate); // 25% of the video bitrate in bytes 
LoadControl loadControl = new DefaultLoadControl(
    new DefaultAllocator(true, 16), 
    TARGET_BUFFER_BYTES, 
    DEFAULT_MIN_REBUFFER_MS,
    DEFAULT_MAX_LOADING_MS,
    DEFAULT_MIN_ELAPSED_MS_BEFORE_STOPPING,
    false
); 
  1. Try using a different Allocator. For example, you could use a larger one:
int allocatorSize = 2 * 1024 * 1024; // 2MB 
Allocator allocator = new DefaultAllocator(true, allocatorSize); 
LoadControl loadControl = new DefaultLoadControl(
    allocator,
    DEFAULT_TARGET_BUFFER_BYTES, 
    DEFAULT_MIN_REBUFFER_MS,
    DEFAULT_MAX_LOADING_MS,
    DEFAULT_MIN_ELAPSED_MS_BEFORE_STOPPING,
    false
); 
摇划花蜜的午后 2025-02-03 08:19:40

将以下内容设置为0->测试行为 - >根据需要进行调整

int MIN_PLAYBACK_RESUME_BUFFER = 1500;
int MIN_PLAYBACK_START_BUFFER = 500;

set the following to 0 -> test behavior -> make adjustments if needed

int MIN_PLAYBACK_RESUME_BUFFER = 1500;
int MIN_PLAYBACK_START_BUFFER = 500;
弱骨蛰伏 2025-02-03 08:19:40

对我有用的是:

    int MIN_BUFFER_DURATION = 3000; // 3 seconds
    int MAX_BUFFER_DURATION = 3000; // 3 seconds
    int MIN_PLAYBACK_RESUME_BUFFER = 1500; // 1.5 seconds
    int MIN_PLAYBACK_START_BUFFER = 500; // 0.5 seconds
    LoadControl loadControl = new DefaultLoadControl.Builder() .setAllocator(new DefaultAllocator(true, 16)) .setBufferDurationsMs(MIN_BUFFER_DURATION, MAX_BUFFER_DURATION, MIN_PLAYBACK_START_BUFFER, MIN_PLAYBACK_RESUME_BUFFER) .setTargetBufferBytes(-1) .setPrioritizeTimeOverSizeThresholds(true).createDefaultLoadControl();
    ExoPlayer player= new ExoPlayer.Builder(this).setLoadControl(loadControl).build();

根据@Carter McKay的答案,答案刚刚改变了max_buffer_duration。

What worked for me was this:

    int MIN_BUFFER_DURATION = 3000; // 3 seconds
    int MAX_BUFFER_DURATION = 3000; // 3 seconds
    int MIN_PLAYBACK_RESUME_BUFFER = 1500; // 1.5 seconds
    int MIN_PLAYBACK_START_BUFFER = 500; // 0.5 seconds
    LoadControl loadControl = new DefaultLoadControl.Builder() .setAllocator(new DefaultAllocator(true, 16)) .setBufferDurationsMs(MIN_BUFFER_DURATION, MAX_BUFFER_DURATION, MIN_PLAYBACK_START_BUFFER, MIN_PLAYBACK_RESUME_BUFFER) .setTargetBufferBytes(-1) .setPrioritizeTimeOverSizeThresholds(true).createDefaultLoadControl();
    ExoPlayer player= new ExoPlayer.Builder(this).setLoadControl(loadControl).build();

as per @Carter McKay answer just changed the MAX_BUFFER_DURATION.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文