comparison docs/html/http/ngx_http_mp4_module.html @ 4111:088ee72d2e57

Regenerated after previous commit.
author Ruslan Ermilov <ru@nginx.com>
date Thu, 15 Sep 2011 08:59:38 +0000
parents
children
comparison
equal deleted inserted replaced
4110:d889195c8db4 4111:088ee72d2e57
1 <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>
2 The module <code>ngx_http_mp4_module</code> provides pseudo-streaming
3 server-side support for H.264/AAC files typically having filename extensions
4 <code>.mp4</code>, <code>.m4v</code>,
5 and <code>.m4a</code>.
6 </p><p>
7 Pseudo-streaming works in alliance with conformant Flash players.
8 A player sends an HTTP request to the server with a start time
9 argument in the request URI’s query string (named simply
10 <code>start</code>
11 and specified in seconds), and the server responds with a stream
12 so that its start position corresponds to the requested time,
13 for example:
14 <blockquote><pre>
15 http://example.com/elephants_dream.mp4?start=238.88
16 </pre></blockquote>
17 This allows for a random seeking at any time, or starting playback
18 in the middle of a timeline.
19 </p><p>
20 To support seeking, H.264-based formats store the metadata
21 in the so-called “moov atom.”
22 It is a part of the file that holds the index information for the
23 whole file.
24 </p><p>
25 To start playback, a player first needs to read metadata.
26 This is done by sending a special request with the
27 <code>start=0</code>
28 argument. Many encoding software will insert the metadata at
29 the end of the file. This is bad for pseudo-streaming:
30 the metadata needs to be located at the beginning of the file,
31 or else the entire file will have to be downloaded before it
32 starts playing. If a file is well-formed (with metadata at the
33 beginning of a file), nginx just sends back the contents of a file.
34 Otherwise, it has to read the file and prepare a new stream so that
35 metadata comes before media data.
36 This involves some CPU, memory, and disk I/O overhead,
37 so it is a good idea to
38 <a href="http://flowplayer.org/plugins/streaming/pseudostreaming.html#prepare">
39 prepare an original file for pseudo-streaming</a>,
40 rather than having nginx do this on every such request.
41 </p><p>
42 For a matching request with a non-zero
43 <code>start</code>
44 argument, nginx will read metadata from the file, prepare the
45 stream starting from the requested offset, and send it to a client.
46 This has the same overhead as described above.
47 </p><p>
48 If a matching request does not include the
49 <code>start</code>
50 argument, there is no overhead, and the file is just sent as a static resource.
51 Some players also support byte-range requests, and thus do not require
52 this module at all.
53 </p><p>
54 This module is not built by default, it should be enabled with the
55 <code>--with-http_mp4_module</code>
56 configuration parameter.
57
58 If you were using the third-party mp4 module, be sure to disable it.
59 </p><p>
60 A similar pseudo-streaming support for FLV files is provided by the module
61 <a href="ngx_http_flv_module.html">ngx_http_flv_module</a>.
62 </p><a name="example"></a><center><h4>Example Configuration</h4></center><p><blockquote><pre>
63 location /video/ {
64 mp4;
65 mp4_buffer_size 1m;
66 mp4_max_buffer_size 5m;
67 }
68 </pre></blockquote></p><a name="directives"></a><center><h4>Directives</h4></center><hr><a name="mp4"></a><strong>syntax</strong>:
69 <code>mp4</code><br><strong>default</strong>:
70 <strong>none</strong><br><strong>context</strong>:
71 <code>location</code><br><p>
72 Turns on module processing in a surrounding location.
73 </p><hr><a name="mp4_buffer_size"></a><strong>syntax</strong>:
74 <code>mp4_buffer_size <code><i>size</i></code></code><br><strong>default</strong>:
75 <code>mp4_buffer_size 512K</code><br><strong>context</strong>:
76 <code>http</code>, <code>server</code>, <code>location</code><br><p>
77 Sets the initial size of a memory buffer used to process MP4 files.
78 </p><hr><a name="mp4_max_buffer_size"></a><strong>syntax</strong>:
79 <code>mp4_max_buffer_size <code><i>size</i></code></code><br><strong>default</strong>:
80 <code>mp4_max_buffer_size 10M</code><br><strong>context</strong>:
81 <code>http</code>, <code>server</code>, <code>location</code><br><p>
82 During metadata processing, a larger buffer may become necessary.
83 Its size cannot exceed the specified <code><i>size</i></code>,
84 or else nginx will return the server error
85 500 (Internal Server Error),
86 and log the following:
87 <blockquote><pre>
88 "/some/movie/file.mp4" mp4 moov atom is too large:
89 12583268, you may want to increase mp4_max_buffer_size
90 </pre></blockquote></p></body></html>