12
votes

I'm having a problem viewing a mp4 file with Google Chrome using HTML5 video tag. The video starts playing just fine and jumping to different position on the timeline also works just fine.

However, I get ERR_CONTENT_LENGTH_MISMATCH error, if I keep watching the video long enough. I noticed that this happens almost every time exactly when the browser has downloaded 124MB (only once at 252MB) of the video. It doesn't matter do I watch the video from the very beginning or do I jump to somewhere on the timeline and start watching, it stops at 124MB. It also doesn't seem to matter what video file I'm using.

The HTML I'm using is quite basic:

<video width="1280" height="720" controls>
    <source src="videos/testvid.mp4" type="video/mp4">
</video>
1
Have you checked the integrity of the the video file? If it's good, your server may be at fault. Make sure it fully supports resume/chunked transfer. - DankMemes
Thanks for the reply. The video files I tried are just fine, so I guess there's something wrong in my server configuration. I'm not very experienced with server configs. What should I look for? I'm running latest XAMPP with Apache 2.4.9. I have read that Apache should have range requests (which is needed) working out of box. The response headers for the video file are 206 Partial Content which would indicate that it should be kinda working correctly. What exactly I should check? - user3519183
Check the content length, the requested bytes, etc. It'll mostly be request headers that you're looking at. - Jessie A. Morris
Have you detected the problem? Could you share the source of your issue? I am having similar problems that I can only randomly reproduce. - Matyas
Same problem there. Several solutions are mentionned. serverfault.com/questions/482875/… - Buzut

1 Answers

2
votes

ERR_CONTENT_LENGTH_MISMATCH appears each time the browser gets from a file more bytes than the reported on Content-Length HTTP response header

There is a few bugs about apache and big files regarding deflating (gzip) and Content-Length header.

We've set up Apache to deflate most web content it serves with gzip, to make file transmission faster with smaller file sizes. This is great for HTML files, CSS and JS files, but for binary files, such as images and media files, or PDFs it can cause problems. For PDFs the problems are that Acrobat can't read PDFs that have been gzipped, so it must be turned off for them.

Source: http://www.beetlebrow.co.uk/what-do-you-need/help-and-documentation/unix-tricks-and-information/apache-gzip-compression-and-binary-files

<Location />
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI  \
    \.(?:gif|jpe?g|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI  \
    \.(?:mp3|wav|wma|au|m4p|snd|mid|wmv|mpg|mpeg|mp4|qt|mov)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
SetEnvIfNoCase Request_URI  \
    \.(?:exe|t?gz|zip|gz2|sit|rar)$ no-gzip dont-vary
</Location>

The solution is to disable compression for certain file types (e.g *.mp4), using rules like this: