﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	uname	nginx_version
266	mp4 sendfile errors	Gernot Vormayr	Maxim Dounin	"After trying out the mp4 module I received some videos didn't work and I got strange errors like:
{{{
2012/12/28 20:16:02 [alert] 17920#0: *39954 sendfile() failed (22: Invalid argument) while sending mp4 to client, client: a.b.c.d, server: , request: ""GET /myfile.mp4?start=26.89 HTTP/1.0"", host: ""a.b.c.d""
}}}
Well yeah I tried turning off sendfile:
{{{
2012/12/28 20:07:08 [emerg] 17864#0: *28769 malloc(18446744073606090997) failed (12: Cannot allocate memory) while sending mp4 to client, client: a.b.c.d, server: , request: ""GET /myfile.mp4?start=26.89 HTTP/1.0"", host: ""a.b.c.d""
}}}

Well since 16PB of ram are a bit too expensive for us I dug into the mp4 code and the mp4 file. Turning on debugging led (as expected) to some nice negative values in the mp4 module. After some more digging I found out, that `ngx_http_mp4_read_mdat_atom` gets called with a zero `atom_data_size` which is correct according to the video:
{{{
xxd -s 714204 -l 8 myfile.mp4 
00ae5dc: 0000 0008 6d64 6174                      ....mdat
}}}

So after some googling I read somewhere that this means that the mdat atom spans the rest of the file? Well I don't know anything about mp4, but I suspect one of you guys knows :)

I believed the text and after applying the patch the file works."	defect	closed	minor		nginx-module	1.2.x	fixed	mp4		Linux k817 2.6.32-5-amd64 #1 SMP Mon Oct 3 03:59:20 UTC 2011 x86_64 GNU/Linux	"nginx version: nginx/1.2.6
TLS SNI support enabled
configure arguments: --prefix=/etc/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 --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_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_stub_status_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6
(package from http://nginx.org/packages/debian/ squeeze nginx)"
