Build enhanced mp4 dynamic module
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Your New SJW Waifu 6de24c9fbf stop complaining 1 week ago
src fastsrart 1 week ago
LICENSE add nginx license 1 week ago
PKGBUILD stop complaining 1 week ago
README.md use tar ball instead 1 week ago
config I think this is right 1 week ago

README.md

ngx_http_enhance_mp4_module

  • 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).

Usage:

  • install

    • git clone https://git.mentality.rip/sjw/ngx_http_enhance_mp4_module.git
    • wget https://nginx.org/download/nginx-1.18.0.tar.gz
    • 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/ngx_http_enhance_mp4_module.so /etc/nginx/modules/
  • like mp4 module, nginx configuration file will look likes this:

    location /video {
                root /mnt/video ;
                enhance_mp4;
                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).

Note:

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