从 URL 加载的 Mp4 文件播放时间过长。

huangapple go评论68阅读模式
英文:

Mp4 file from Url is taking too long to play

问题

MediaSource videoSource = new 
ExtractorMediaSource.Factory(dataSourceFactory)
            .createMediaSource(mUri);
// Prepare the player with the source.
Log.d("exo","to be prepare");
player.prepare(videoSource);
Log.d("exo","prepared"+videoSource);

player.setPlayWhenReady(true);
Log.d("exo","played");

player.addListener(this);

============================
LoadControl loadControl = new DefaultLoadControl(
                new DefaultAllocator(true, 16),
                VideoPlayerConfig.MIN_BUFFER_DURATION,
                VideoPlayerConfig.MAX_BUFFER_DURATION,
                VideoPlayerConfig.MIN_PLAYBACK_START_BUFFER,
                VideoPlayerConfig.MIN_PLAYBACK_RESUME_BUFFER, -1, true);

        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);
        // 2. Create the player
        player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), trackSelector, loadControl);
        videoFullScreenPlayer.setPlayer(player);
英文:

I have a mp4 Url, which is containing 400mb of video.
Using exoplayer, it's taking too long (10-15 min) for start the playing the video.
I have added loadcontrol but no use. Can anybody help me ?

  MediaSource videoSource = new 
  ExtractorMediaSource.Factory(dataSourceFactory)
            .createMediaSource(mUri);
    // Prepare the player with the source.
    Log.d("exo","to be prepare");
    player.prepare(videoSource);
    Log.d("exo","prepared"+videoSource);

    player.setPlayWhenReady(true);
    Log.d("exo","played");

    player.addListener(this);

============================

LoadControl loadControl = new DefaultLoadControl(
new DefaultAllocator(true, 16),
VideoPlayerConfig.MIN_BUFFER_DURATION,
VideoPlayerConfig.MAX_BUFFER_DURATION,
VideoPlayerConfig.MIN_PLAYBACK_START_BUFFER,
VideoPlayerConfig.MIN_PLAYBACK_RESUME_BUFFER, -1, true);

        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);
        // 2. Create the player
        player = ExoPlayerFactory.newSimpleInstance(new DefaultRenderersFactory(this), trackSelector, loadControl);
        videoFullScreenPlayer.setPlayer(player);

答案1

得分: 0

这可能有多个原因:

1. 最大缓冲持续时间过长

尝试将VideoPlayerConfig.MAX_BUFFER_DURATION的值设置得较低(似乎为30秒显然

2. 您的流媒体视频协议效率不高

这可能与视频编码结合您的网络速度限制有关。我猜测视频播放器在播放之前加载了整个视频,或者至少加载了大量视频内容。这就是为什么诸如“HTTP Live Stream”之类的协议可以解决这个问题,并导致视频几乎立即播放,因为该协议发送视频块并根据需要动态调整带宽。

3. 您的互联网连接较慢

尽管这可能不是主要原因,但可能会影响结果。

英文:

This might have multiple causes:

1. The max buffer duration is too large

Try to play with setting a lower value for VideoPlayerConfig.MAX_BUFFER_DURATION (which is 30 seconds apparently)

2. Your streaming video protocol is not efficient

It possibly has to do with the video encoding in combination with your network speed limitations. I'm guessing that the video player is loading the entire video, or at least a massive chunk of it) before it plays. That's why Protocols like "HTTP Live Stream" solve this problem and lead to videos playing nearly instantly, as the protocol sends chunks of videos, and adjusts the bandwidth dynamically.

3. Your internet connection is relatively slow

While this is probably not the main cause, it might affect the outcome.

答案2

得分: 0

我已经实现了CDN,而且它正常工作。

英文:

I have implemented CDN and it's working fine

huangapple
  • 本文由 发表于 2020年10月3日 20:02:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/64184025.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定