简体   繁体   English

来自 Url 的 Mp4 文件播放时间太长

[英]Mp4 file from Url is taking too long to play

I have a mp4 Url, which is containing 400mb of video.我有一个 mp4 Url,其中包含 400mb 的视频。 Using exoplayer, it's taking too long (10-15 min) for start the playing the video.使用 exoplayer,开始播放视频需要很长时间(10-15 分钟)。 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); 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);

This might have multiple causes:这可能有多种原因:

1. The max buffer duration is too large 1.最大缓冲时长过大

Try to play with setting a lower value for VideoPlayerConfig.MAX_BUFFER_DURATION (which is 30 seconds apparently )尝试为VideoPlayerConfig.MAX_BUFFER_DURATION设置一个较低的值( 显然30 seconds

2. Your streaming video protocol is not efficient 2.您的流媒体视频协议效率不高

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.这就是为什么像“HTTP Live Stream”这样的协议解决了这个问题并导致视频几乎立即播放,因为该协议发送视频块并动态调整带宽。

3. Your internet connection is relatively slow 3. 您的网络连接速度较慢

While this is probably not the main cause, it might affect the outcome.虽然这可能不是主要原因,但它可能会影响结果。

我已经实施了 CDN 并且运行良好

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM