Build enhanced mp4 dynamic module
Go to file
Your New SJW Waifu 6de24c9fbf stop complaining 2021-04-05 14:38:11 -05:00
src fastsrart 2021-04-05 12:51:54 -05:00
LICENSE add nginx license 2021-04-05 11:44:10 -05:00
PKGBUILD stop complaining 2021-04-05 14:38:11 -05:00 use tar ball instead 2021-04-05 12:54:05 -05:00
config I think this is right 2021-04-05 12:50:03 -05:00


  • This module is an enhance version of original nginx mp4 module (which shipped into nginx source code). Please note this is my own project, it has nothing related with nginx's source code except it takes all source code of ngx_http_mp4_module.

  • This module enable nginx mp4 module to modify mp4 file (which moov atom place in the last of file) on the fly (just one time), then deliver it to video player.

This is why

  • In order to deliver HTTP (RTMP and other can do better) video on demand (using ngx_http_mp4_module) the right way: player just has to download:
    1. the ftyp atom and check that the container format, version and branding are supported.
    2. moov atom, check that the required codec are available and use the "stco" sub-atoms to start decoding the video and audio streams.

The whole data is mdat atom, which can be buffered, decompressed and play later.

The ftyp and moov atom are just few KB, so if these atom are placed in the begining of the file, every player can start progressive download just after download them. Most of video encoder/muxer/demuxer (without doing 2 pass encoding) place moov atom in the last of the file, which cause progressive playback has problem. Browser has to download the whole file in order to start playing that file, it's not progressive playback anymore.

These tools above require you to do this at encoding step: convert the file, standardise it. Using this module, you dont have to standarlise using above tool anymore (you still have to convert file into Quick time format).


  • install

    • git clone
    • wget
    • tar xzvf nginx-1.18.0.tar.gz
    • cd nginx-1.18.0
    • ./configure --with-compat --add-dynamic-module=../ngx_http_enhance_mp4_module
    • make modules
    • sudo cp objs/ /etc/nginx/modules/
  • like mp4 module, nginx configuration file will look likes this:

    location /video {
                root /mnt/video ;
                fix_mp4 on;
                enhance_mp4_buffer_size 1m;
                enhance_mp4_max_buffer_size 50m;
  • which:
    • enhance_mp4, enhance_mp4_buffer_size, enhance_mp4_max_buffer_size are the same with mp4, mp4_buffer_size, and mp4_max_buffer_size directives from the original module.
    • fix_mp4: when it is on, mp4 file will be fixed if needed, if moov atom is place in right order, we dont have to fix it. if it is off, this module works exactly the way nginx mp4 module do (so why you use it).


  • To make it less conflict with nginx mp4 module, I've tried to change its namespace from ngx_mp4 -> ngx_enhance_mp4.