Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5 video being downloaded 'twice' for no reason

I was just wondering why sometimes browsers need to call an HTML5 video twice before playing it. Is that normal or it's actually a bug? What happens under the hood?

Not sure my question is particularly easy to understand I took a screenshot from http://videojs.com homepage, with the network panel open, in order to help me explain it. Please check out http://bit.ly/St4rRc. The same happens with this famous page http://www.apple.com/html5/showcase/video/ made by Apple, which BTW doesn't use any javascript library for the video. I am testing it on Google Chrome/Windows.

Thanks,

Iz

like image 704
Izaias Avatar asked Nov 30 '12 22:11

Izaias


People also ask

Why is HTML5 video not working?

If you come across an HTML5 page with the following error message “file not found,” then it means your browser doesn't have the proper video codec installed. For example, if you are using Google Chrome and you come across an HTML5 MP4 video, then you may get an error message because you don't have an MP4 codec.

Can you save HTML5 videos?

This video format is compatible with browsers that support HTML5 technology, including most of the latest browsers and Safari, which is used on iPhone, iPad, and iPod touch devices. You can save your HTML5 video projects directly to cloud-based storage services, such as Dropbox and Google Drive.


2 Answers

Many media files have some kind of structure at the end of the file that defines locations of atoms or other metadata about the media such as duration, start byte offset, codecs, bitrate, etc. Some file types like mp4 containers can be "hinted" to move this data to the beginning of the file. Historically this info is concatenated to the end of the media file because many of the values (duration) aren't known until the video has finished encoding.

like image 108
jeremy Avatar answered Sep 22 '22 12:09

jeremy


The first call is the preload. This allows the video to be ready to play as soon as the user clicks the play button assuming it's not autoplay, or as early as possible otherwise. After downlading the metadata and the first few seconds of video, it is aborted.

The second call actually fetches the whole file. Browsers will try to request only the part that wasn't already requested, but the server needs to be configured to allow that.

like image 30
Niet the Dark Absol Avatar answered Sep 22 '22 12:09

Niet the Dark Absol