Mercurial > hg > nginx
changeset 4111:088ee72d2e57
Regenerated after previous commit.
author | Ruslan Ermilov <ru@nginx.com> |
---|---|
date | Thu, 15 Sep 2011 08:59:38 +0000 |
parents | d889195c8db4 |
children | bc0ca958c270 |
files | docs/html/http/ngx_http_mp4_module.html |
diffstat | 1 files changed, 90 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
new file mode 100644 --- /dev/null +++ b/docs/html/http/ngx_http_mp4_module.html @@ -0,0 +1,90 @@ +<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>HTTP MP4 Module</title></head><body><center><h3>HTTP MP4 Module</h3></center><center><h4>Summary</h4></center><p> +The module <code>ngx_http_mp4_module</code> provides pseudo-streaming +server-side support for H.264/AAC files typically having filename extensions +<code>.mp4</code>, <code>.m4v</code>, +and <code>.m4a</code>. +</p><p> +Pseudo-streaming works in alliance with conformant Flash players. +A player sends an HTTP request to the server with a start time +argument in the request URI’s query string (named simply +<code>start</code> +and specified in seconds), and the server responds with a stream +so that its start position corresponds to the requested time, +for example: +<blockquote><pre> +http://example.com/elephants_dream.mp4?start=238.88 +</pre></blockquote> +This allows for a random seeking at any time, or starting playback +in the middle of a timeline. +</p><p> +To support seeking, H.264-based formats store the metadata +in the so-called “moov atom.” +It is a part of the file that holds the index information for the +whole file. +</p><p> +To start playback, a player first needs to read metadata. +This is done by sending a special request with the +<code>start=0</code> +argument. Many encoding software will insert the metadata at +the end of the file. This is bad for pseudo-streaming: +the metadata needs to be located at the beginning of the file, +or else the entire file will have to be downloaded before it +starts playing. If a file is well-formed (with metadata at the +beginning of a file), nginx just sends back the contents of a file. +Otherwise, it has to read the file and prepare a new stream so that +metadata comes before media data. +This involves some CPU, memory, and disk I/O overhead, +so it is a good idea to +<a href="http://flowplayer.org/plugins/streaming/pseudostreaming.html#prepare"> +prepare an original file for pseudo-streaming</a>, +rather than having nginx do this on every such request. +</p><p> +For a matching request with a non-zero +<code>start</code> +argument, nginx will read metadata from the file, prepare the +stream starting from the requested offset, and send it to a client. +This has the same overhead as described above. +</p><p> +If a matching request does not include the +<code>start</code> +argument, there is no overhead, and the file is just sent as a static resource. +Some players also support byte-range requests, and thus do not require +this module at all. +</p><p> +This module is not built by default, it should be enabled with the +<code>--with-http_mp4_module</code> +configuration parameter. + +If you were using the third-party mp4 module, be sure to disable it. +</p><p> +A similar pseudo-streaming support for FLV files is provided by the module +<a href="ngx_http_flv_module.html">ngx_http_flv_module</a>. +</p><a name="example"></a><center><h4>Example Configuration</h4></center><p><blockquote><pre> +location /video/ { + mp4; + mp4_buffer_size 1m; + mp4_max_buffer_size 5m; +} +</pre></blockquote></p><a name="directives"></a><center><h4>Directives</h4></center><hr><a name="mp4"></a><strong>syntax</strong>: + <code>mp4</code><br><strong>default</strong>: + <strong>none</strong><br><strong>context</strong>: + <code>location</code><br><p> +Turns on module processing in a surrounding location. +</p><hr><a name="mp4_buffer_size"></a><strong>syntax</strong>: + <code>mp4_buffer_size <code><i>size</i></code></code><br><strong>default</strong>: + <code>mp4_buffer_size 512K</code><br><strong>context</strong>: + <code>http</code>, <code>server</code>, <code>location</code><br><p> +Sets the initial size of a memory buffer used to process MP4 files. +</p><hr><a name="mp4_max_buffer_size"></a><strong>syntax</strong>: + <code>mp4_max_buffer_size <code><i>size</i></code></code><br><strong>default</strong>: + <code>mp4_max_buffer_size 10M</code><br><strong>context</strong>: + <code>http</code>, <code>server</code>, <code>location</code><br><p> +During metadata processing, a larger buffer may become necessary. +Its size cannot exceed the specified <code><i>size</i></code>, +or else nginx will return the server error +500 (Internal Server Error), +and log the following: +<blockquote><pre> +"/some/movie/file.mp4" mp4 moov atom is too large: +12583268, you may want to increase mp4_max_buffer_size +</pre></blockquote></p></body></html>