FAQ

Page Discussion Edit History

HttpMp4Module

Revision as of 15:11, 24 August 2012 by Ensiferous (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Contents

[edit] Synopsis

This module enables mp4 streaming with seeking ability. This module is not compiled by default and must be specified using

--with-http_mp4_module

as an argument to configure when compiling Nginx. Note that this module is only supported in nginx version 1.1.3 and higher in development branch and 1.0.7 in stable branch.

[edit] Example usage:

location /video/ {
    mp4;
    mp4_buffer_size     1m;
    mp4_max_buffer_size 5m;
}

[edit] 
Directives

[edit] mp4

Syntax: mp4
Default:
Context: location
Reference:mp4


Enables the mp4 streaming feature.

location /video {
    mp4 on; 
}

[edit] mp4_buffer_size

Syntax: mp4_buffer_size size
Default: 512K
Context: http
server
location
Reference:mp4_buffer_size


Sets the buffer size used for processing mp4 file.

[edit] mp4_max_buffer_size

Syntax: mp4_max_buffer_size size
Default: 10M
Context: http
server
location
Reference:mp4_max_buffer_size


Sets the maxium buffer size used for processing mp4 file. If the meta data exceeds this size Nginx will return a 500 status code and log an error resembling the following:

"/video/file.mp4" mp4 moov atom is too large:
12583268, you may want to increase mp4_max_buffer_size

[edit] Notes

This module does not as of 1.3.4 support seeking through embedded subtitle tracks. Though this is a forced limitation and it works fine without it. There is a patch to enable this functionality.

Update: This is now fixed in 1.3.5 and no longer required.

--- a/src/http/modules/ngx_http_mp4_module.c
+++ b/src/http/modules/ngx_http_mp4_module.c
@@ -1842,14 +1842,6 @@ ngx_http_mp4_read_stsd_atom(ngx_http_mp4
                    ngx_mp4_get_32value(stsd_atom->entries),
                    4, stsd_atom->media_name);
 
-    /* supported media format: "avc1" (H.264) and "mp4a" (MPEG-4/AAC) */
-
-    if (ngx_strncmp(stsd_atom->media_name, "avc1", 4) != 0
-        && ngx_strncmp(stsd_atom->media_name, "mp4a", 4) != 0)
-    {
-        return NGX_DECLINED;
-    }
-
     trak = ngx_mp4_last_trak(mp4);
 
     atom = &trak->stsd_atom_buf;

Please note that to avoid excessive seeking time the MP4 files have to use sample based interleaving of the media tracks and hint tracks. MP4Box provides this functionality through the -tight parameter.

For reference please see the following bug report: http://trac.nginx.org/nginx/ticket/194

[edit] References

Please see the following page for more details: http://nginx.org/en/docs/http/ngx_http_mp4_module.html