Search code examples
httpservletsvideo-streamingmp4http-streaming

Http video streaming needs to download full video data to start play?


In my server two mp4 file is available. When I browse the video1.mp4 url from my browser, it started to play the video file in browser.

If I play video2.mp4 url from browser,it takes long to start playing.

At that time I had checked the browsers temp file, It downloads the full video then only it starts to play. After clearing the temp file i had tried to play the video1. It takes some amount of file only.(Video1 size is 800 MB, temp memory has 50 MB only, Video2 size is 500 MB, temp memory also has the 500 MB)

What is the difference between two video files. Both are MP4 only. But one takes full video data and another one takes partial amount of video file, why ?


Solution

  • The two files are encoded differently. MP4 files are divided in packets called boxes, the box that describes the type of compression and the different tracks that are present in the video file is a 'moov' box, and traditionally it lives at the end of the file, but encoding software can be configured to generate it at the beginning.

    For example, if you use ffmpeg you can use the qt-faststart option to enable putting the metadata at the beginning.