Progressive download (http_mp4): delays before responding with actual data streams
|Reported by:||Maxim Novikov||Owned by:|
|Keywords:||http mp4 pseudo streaming||Cc:||csbubbles@…|
|uname -a:||Linux 2.6.32-358.23.2.el6.x86_64|
nginx version: nginx/1.0.15
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/share/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/tmp/client_body --http-proxy-temp-path=/var/lib/nginx/tmp/proxy --http-fastcgi-temp-path=/var/lib/nginx/tmp/fastcgi --http-uwsgi-temp-path=/var/lib/nginx/tmp/uwsgi --http-scgi-temp-path=/var/lib/nginx/tmp/scgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/subsys/nginx --user=nginx --group=nginx --with-file-aio --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_geoip_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_degradation_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module --with-debug --with-cc-opt='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic' --with-ld-opt=-Wl,-E
I am trying to utilize nginx's hhtp_mp4 module for progressive download. In general it works fine, but there is an issue that looks like a deal breaker to me.
There is a delay after sending the request and before receiving the actual byte stream, and it apparently depends on the size of a file. For example, for a 3mb file this pause is about 0.5 second, whereas for a 75mb file it is 5 seconds. My assumption is that the http_mp4 module analyzes the content of the file before starting streaming it (maybe calculating its length or playing time, etc.), and for big files it may take a while.
All my files are AAC-encoded audio (.mp4 files). What I wanted to actually achieve using this module is a media storage for audio players on different platforms. But you can understand that the behavior described above would be inappropriate for such purposes, as it brings huge delays sometimes when the player is trying to change an audio track.
Is it the expected behavior? Can it be solved enabling some sort of "caching" that would allow the http_mp4 module to pre-scan all the information required in advance and to not spend time on this when processing HTTP requests? Is there some configuration I have missed?
I would appreciate any suggestions how to solve this issue, but my expectations would be to start receiving the audio payload immediately.
PS I am attaching screenshots where you can see the pauses for files of various sizes (a.png - handling a 75mb file, b.png - 3.5mb file).