Mp4 module

I’ve commit ngx_http_mp4_module in trunk branch.
The patch for 1.0 and last 0.8 is also available:
http://nginx.org/patches/patch.mp4.txt

The module was tested against JW Player.

The module is not built by default, it should be enabled with
–with-http_mp4_module
If you use 3rd-party mp4 module, it should be removed.
Configuration:

location /mp4/ {
mp4;
mp4_buffer_size 1m; # default 512k
mp4_max_moov_size 10m; # default 5m
}

mp4_buffer_size - initial size of buffer to read mp4 file.
This buffer is also used to keep whole meta data of mp4 file (so
called “moov” atom). Maximum size of moov atom which nginx is capable
to read is set by mp4_max_moov_size.


Igor S.

That’s a good feature
Can you confirm if it’s compatible with proxy cache?

On Fri, Sep 09, 2011 at 12:16:35PM +0000, Richard K. wrote:

That’s a good feature
Can you confirm if it’s compatible with proxy cache?

No, currently it can work only with static files.


Igor S.

On Mon, Sep 12, 2011 at 03:20:28PM -0400, meto wrote:

Can’t wait to see that feature in mainline (dev or stable). It’s one
that was bugging me about the license used by current one (commercial
use).

Changes with nginx 1.1.3 14 Sep
2011

*) Feature: the module ngx_http_mp4_module.

Or you can use the following patch with nginx-1.0:
http://nginx.org/patches/patch.mp4.3.txt

Documentation is here:
http://nginx.org/en/docs/http/ngx_http_mp4_module.html

Are you planning to include it in your repo packages?

Yes.


Igor S.

Can’t wait to see that feature in mainline (dev or stable). It’s one
that was bugging me about the license used by current one (commercial
use). Are you planning to include it in your repo packages?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215011,215129#msg-215129

2011/09/15 11:22:44 [error] 29330#0: *6 no mp4 stco atoms were found in
“/usr/local/opt/nginx_new/html/video/v.mp4”, client: 10.10.50.130,
server:
localhost, request: “GET /video/v.mp4?start=43.4 HTTP/1.1”

2011/9/15 Igor S. [email protected]

On Thu, Sep 15, 2011 at 11:25:36AM +0800, C.F wrote:

2011/09/15 11:22:44 [error] 29330#0: *6 no mp4 stco atoms were found in
“/usr/local/opt/nginx_new/html/video/v.mp4”, client: 10.10.50.130, server:
localhost, request: “GET /video/v.mp4?start=43.4 HTTP/1.1”

Could you create debug log of the request ?
http://nginx.org/en/docs/debugging_log.html

Is this file larger than 4G ?


Igor S.

On Thu, Sep 15, 2011 at 12:39:49PM +0800, C.F wrote:

-rw-r–r-- 1 root root 39493113 09-15 11:20 v.mp4

2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: co64 @30817:784

Thank you. As I supposed it has 64-bit co64 atom, however, it’s strange
that this atom was used for so small size file - 39M.
I will make patch today.


Igor S.

-rw-r–r-- 1 root root 39493113 09-15 11:20 v.mp4

debug_log

2011/09/15 12:36:58 [debug] 31923#0: *2 http mp4 filename:
“/usr/local/opt/nginx_n1/html/video/v.mp4”
2011/09/15 12:36:58 [debug] 31923#0: *2 add cleanup: 000000001D7A10E0
2011/09/15 12:36:58 [debug] 31923#0: *2 malloc: 000000001D799D00:5752
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 start:21700
2011/09/15 12:36:58 [debug] 31923#0: *2 malloc: 000000001D7EC230:1048576
2011/09/15 12:36:58 [debug] 31923#0: *2 read: 10, 000000001D7EC230,
1048576,
0
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: ftyp @0:24
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 ftyp atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: moov @24:31577
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 moov atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: mvhd @32:108
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 mvhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mvhd timescale:1000,
duration:104977, time:104.977s
2011/09/15 12:36:58 [debug] 31923#0: *2 mvhd new duration:83277,
time:83.277s
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: trak @140:19371
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 trak atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: tkhd @148:92
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 tkhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 tkhd duration:104977,
time:104.977s
2011/09/15 12:36:58 [debug] 31923#0: *2 tkhd new duration:83277,
time:83.277s
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: mdia @240:19271
2011/09/15 12:36:58 [debug] 31923#0: *2 process mdia atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: mdhd @248:32
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 mdhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mdhd timescale:44100,
duration:4629504, time:104.977s
2011/09/15 12:36:58 [debug] 31923#0: *2 mdhd new duration:3672534,
time:83.277s
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: hdlr @280:44
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 hdlr atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: minf @324:19187
2011/09/15 12:36:58 [debug] 31923#0: *2 process minf atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: smhd @332:16
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 smhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: dinf @348:36
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 dinf atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stbl @384:19127
2011/09/15 12:36:58 [debug] 31923#0: *2 process stbl atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stsd @392:91
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 stsd entries:1, media:mp4a
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stts @483:32
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stts atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 time-to-sample entries:2
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stsz @515:18104
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsz atom
2011/09/15 12:36:58 [debug] 31923#0: *2 sample uniform size:0,
entries:4521
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stsc @18619:52
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsc atom
2011/09/15 12:36:58 [debug] 31923#0: *2 sample-to-chunk entries:3
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: co64 @18671:840
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 trak atom: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: trak @19511:12090
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 trak atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: tkhd @19519:92
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 tkhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 tkhd duration:104692,
time:104.692s
2011/09/15 12:36:58 [debug] 31923#0: *2 tkhd new duration:82992,
time:82.992s
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: edts @19611:48
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: mdia @19659:11942
2011/09/15 12:36:58 [debug] 31923#0: *2 process mdia atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: mdhd @19667:32
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 mdhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mdhd timescale:90000,
duration:9422237, time:104.692s
2011/09/15 12:36:58 [debug] 31923#0: *2 mdhd new duration:7469237,
time:82.992s
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: hdlr @19699:44
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 hdlr atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: minf @19743:11858
2011/09/15 12:36:58 [debug] 31923#0: *2 process minf atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: vmhd @19751:20
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 vmhd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: dinf @19771:36
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 dinf atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stbl @19807:11794
2011/09/15 12:36:58 [debug] 31923#0: *2 process stbl atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stsd @19815:150
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsd atom
2011/09/15 12:36:58 [debug] 31923#0: *2 stsd entries:1, media:avc1
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stts @19965:6416
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stts atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 time-to-sample entries:800
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stss @26381:152
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stss atom
2011/09/15 12:36:58 [debug] 31923#0: *2 sync sample entries:34
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stsz @26533:4208
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsz atom
2011/09/15 12:36:58 [debug] 31923#0: *2 sample uniform size:0,
entries:1047
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: stsc @30741:76
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsc atom
2011/09/15 12:36:58 [debug] 31923#0: *2 sample-to-chunk entries:5
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: co64 @30817:784
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 trak atom: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 moov atom done
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: free @31601:778423
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: mdat @810024:38683089
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 mdat atom
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stts atom update
2011/09/15 12:36:58 [debug] 31923#0: *2 time-to-sample start_time:956970
2011/09/15 12:36:58 [debug] 31923#0: *2 count:1, duration:1024
2011/09/15 12:36:58 [debug] 31923#0: *2 count:4520, duration:1024
2011/09/15 12:36:58 [debug] 31923#0: *2 start_sample:934, new count:3586
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stss atom update
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 ctts atom update
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsc atom update
2011/09/15 12:36:58 [debug] 31923#0: *2 start_sample:934, chunk:1,
chunks:1,
samples:46, id:1
2011/09/15 12:36:58 [debug] 31923#0: *2 start_sample:888, chunk:2,
chunks:101, samples:44, id:1
2011/09/15 12:36:58 [debug] 31923#0: *2 start chunk:21, samples:8
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stsz atom update
2011/09/15 12:36:58 [debug] 31923#0: *2 chunk samples sizes:1489
2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 stco atom update
2011/09/15 12:36:58 [error] 31923#0: *2 no mp4 stco atoms were found in
“/usr/local/opt/nginx_n1/html/video/v.mp4”, client: 10.10.50.130,
server:
localhost, request: “GET /video/v.mp4?start=21.7 HTTP/1.1”, host: "
192.168.51.31:3080"
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D7EC230
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D799D00
2011/09/15 12:36:58 [debug] 31923#0: *2 http finalize request: 500,
“/video/v.mp4?start=21.7” a:1, c:1
2011/09/15 12:36:58 [debug] 31923#0: *2 http special response: 500,
“/video/v.mp4?start=21.7”
2011/09/15 12:36:58 [debug] 31923#0: *2 internal redirect: “/50x.html?”
2011/09/15 12:36:58 [debug] 31923#0: *2 rewrite phase: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 test location: “/”
2011/09/15 12:36:58 [debug] 31923#0: *2 test location: “video/”
2011/09/15 12:36:58 [debug] 31923#0: *2 test location: “50x.html”
2011/09/15 12:36:58 [debug] 31923#0: *2 using configuration “=/50x.html”
2011/09/15 12:36:58 [debug] 31923#0: *2 http cl:-1 max:1048576
2011/09/15 12:36:58 [debug] 31923#0: *2 rewrite phase: 2
2011/09/15 12:36:58 [debug] 31923#0: *2 post rewrite phase: 3
2011/09/15 12:36:58 [debug] 31923#0: *2 generic phase: 4
2011/09/15 12:36:58 [debug] 31923#0: *2 generic phase: 5
2011/09/15 12:36:58 [debug] 31923#0: *2 access phase: 6
2011/09/15 12:36:58 [debug] 31923#0: *2 access phase: 7
2011/09/15 12:36:58 [debug] 31923#0: *2 post access phase: 8
2011/09/15 12:36:58 [debug] 31923#0: *2 content phase: 9
2011/09/15 12:36:58 [debug] 31923#0: *2 content phase: 10
2011/09/15 12:36:58 [debug] 31923#0: *2 content phase: 11
2011/09/15 12:36:58 [debug] 31923#0: *2 http filename:
“/usr/local/opt/nginx_n1/html/50x.html”
2011/09/15 12:36:58 [debug] 31923#0: *2 add cleanup: 000000001D7A1170
2011/09/15 12:36:58 [debug] 31923#0: *2 http static fd: 11
2011/09/15 12:36:58 [debug] 31923#0: *2 http set discard body
2011/09/15 12:36:58 [debug] 31923#0: *2 HTTP/1.1 500 Internal Server
Error
Server: nginx/1.1.3
Date: Thu, 15 Sep 2011 04:36:58 GMT
Content-Type: text/html
Content-Length: 383
Connection: close

2011/09/15 12:36:58 [debug] 31923#0: *2 write new buf t:1 f:0
000000001D7A1308, pos 000000001D7A1308, size: 161 file: 0, size: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 http write filter: l:0 f:0 s:161
2011/09/15 12:36:58 [debug] 31923#0: *2 http output filter “/50x.html?”
2011/09/15 12:36:58 [debug] 31923#0: *2 http copy filter: “/50x.html?”
2011/09/15 12:36:58 [debug] 31923#0: *2 http postpone filter
“/50x.html?”
00007FFF6568DA30
2011/09/15 12:36:58 [debug] 31923#0: *2 write old buf t:1 f:0
000000001D7A1308, pos 000000001D7A1308, size: 161 file: 0, size: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 write new buf t:0 f:1
0000000000000000, pos 0000000000000000, size: 0 file: 0, size: 383
2011/09/15 12:36:58 [debug] 31923#0: *2 http write filter: l:1 f:0 s:544
2011/09/15 12:36:58 [debug] 31923#0: *2 http write filter limit 0
2011/09/15 12:36:58 [debug] 31923#0: *2 writev: 161
2011/09/15 12:36:58 [debug] 31923#0: *2 sendfile: @0 383
2011/09/15 12:36:58 [debug] 31923#0: *2 sendfile: 383, @0 383:383
2011/09/15 12:36:58 [debug] 31923#0: *2 http write filter
0000000000000000
2011/09/15 12:36:58 [debug] 31923#0: *2 http copy filter: 0 “/50x.html?”
2011/09/15 12:36:58 [debug] 31923#0: *2 http finalize request: 0,
“/50x.html?” a:1, c:2
2011/09/15 12:36:58 [debug] 31923#0: *2 http request count:2 blk:0
2011/09/15 12:36:58 [debug] 31923#0: *2 http finalize request: -4,
“/50x.html?” a:1, c:1
2011/09/15 12:36:58 [debug] 31923#0: *2 event timer add: 3:
5000:1316061423751
2011/09/15 12:36:58 [debug] 31923#0: *2 http lingering close handler
2011/09/15 12:36:58 [debug] 31923#0: *2 recv: fd:3 -1 of 4096
2011/09/15 12:36:58 [debug] 31923#0: *2 recv() not ready (11: Resource
temporarily unavailable)
2011/09/15 12:36:58 [debug] 31923#0: *2 lingering read: -2
2011/09/15 12:36:58 [debug] 31923#0: *2 event timer: 3, old:
1316061423751,
new: 1316061423751
2011/09/15 12:36:58 [debug] 31923#0: *2 http lingering close handler
2011/09/15 12:36:58 [debug] 31923#0: *2 recv: fd:3 0 of 4096
2011/09/15 12:36:58 [debug] 31923#0: *2 lingering read: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 http request count:1 blk:0
2011/09/15 12:36:58 [debug] 31923#0: *2 http close request
2011/09/15 12:36:58 [debug] 31923#0: *2 http log handler
2011/09/15 12:36:58 [debug] 31923#0: *2 run cleanup: 000000001D7A1170
2011/09/15 12:36:58 [debug] 31923#0: *2 file cleanup: fd:11
2011/09/15 12:36:58 [debug] 31923#0: *2 run cleanup: 000000001D7A10E0
2011/09/15 12:36:58 [debug] 31923#0: *2 file cleanup: fd:10
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 0000000000000000
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 0000000000000000
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D7A06E0, unused:
480
2011/09/15 12:36:58 [debug] 31923#0: *2 close http connection: 3
2011/09/15 12:36:58 [debug] 31923#0: *2 event timer del: 3:
1316061423751
2011/09/15 12:36:58 [debug] 31923#0: *2 reusable connection: 0
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D7A02D0
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D79FDE0
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D7AA640, unused:
8
2011/09/15 12:36:58 [debug] 31923#0: *2 free: 000000001D795390, unused:
128

On Thu, Sep 15, 2011 at 08:53:54AM +0400, Igor S. wrote:

On Thu, Sep 15, 2011 at 12:39:49PM +0800, C.F wrote:

-rw-r–r-- 1 root root 39493113 09-15 11:20 v.mp4

2011/09/15 12:36:58 [debug] 31923#0: *2 mp4 atom: co64 @30817:784

Thank you. As I supposed it has 64-bit co64 atom, however, it’s strange
that this atom was used for so small size file - 39M.
I will make patch today.

Patch for nginx-1.1.3.

I am very curious about what the difference between this modle and the
3rd
modle(http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Nginx-Version2).
Which one should I use?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215011,215506#msg-215506

To quote Igors original post: “If you use 3rd-party mp4 module, it
should be removed.”

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215011,215577#msg-215577

To my understanding both mod-h264 (code-shop) and mod-mp4 (nginx) are
very similar, as they allow seeking in mp4 files.

The mod_smooth_streaming for Code-shop is the one that is different.

Regards,

Pierig Le Saux

----- Mail original -----
De: “ahu” [email protected]
À: [email protected]
Envoyé: Mercredi 21 Septembre 2011 16:18:31
Objet: Re: mp4 module

I am very curious about what the difference between this modle and the
3rd
modle(http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Nginx-Version2).
Which one should I use?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215011,215506#msg-215506


nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx

for me,“If you use 3rd-party mp4 module, it should be removed.” just
means they are different.I want to know the detail :slight_smile:
Should I use the official mp4 module instead of the 3rd-party one?

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215011,215678#msg-215678

Ok,I get it.Thanks very much.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,215011,215751#msg-215751

On Sep 23, 2011, at 5:01 , ahu wrote:

for me,“If you use 3rd-party mp4 module, it should be removed.” just
means they are different.I want to know the detail :slight_smile:
Should I use the official mp4 module instead of the 3rd-party one?

You should use only one of them. If you have issues with 3rd-party,
you can try the official mp4 module. If you have issues with the
official module, you should report them and I wll try to fix them.


Igor S.
http://sysoev.ru/en/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs