Search code examples
djangomp3mp4x-sendfile

mp3 sent OK, but mp4 not (Django & X-Sendfile)


Apon clicking play on my web page, an mp3 file is sent from the server and in the browser see only 3 requests sent. I added to the response X-Sendfile header, and the responds arrived without it so I understand mod_xsendfile is configured OK.

Weirdly, when I click play on mp4, the browser start sending hundreds of requests, and the movie starts and gets stuck! No "X-Sendfile" header in responses here eather...

If I change the source in the cideo element to some mp4 file of a different site - all is OK (movie runs smoothly & only few requests).

What is the problem?

Some Code...

HTML:

<video id="videoId" preload="none" controls="controls" width="300px" height="286px" src="url/of/file.mp4">
    Sorry, unable to play video.
</video>

.htaccess:

<filesMatch "\.(mp3|ogg|mp4)$">
    XSendFile on
</filesMatch>

Response Header: (of mp4)

Accept-Ranges:bytes
Connection:Keep-Alive
Content-Disposition:filename=fileName.mp4
Content-Length:1392497
Content-Range:bytes 8382477-9774973/9774974
Content-Type:video/mp4
Date:Sat, 28 Apr 2012 20:27:07 GMT
Keep-Alive:timeout=5, max=100
Last-Modified:Sat, 14 Apr 2012 12:47:10 GMT
Server:Apache

Solution

  • The problem was... the encoding of MP4 file!