Gridfs in mongodb is suitable for storing ultra-large files such as videos and HD images (small files are not recommended in mongodb );
Configure nginx in centos to access the mp4 file in mongodb:
1: Install nginx-gridfs
Git clone https://github.com/rjhunjhunwla/nginx-gridfs // If git does not exist: yum-y install git
Cd nginx-gridfs/
Git submodule init
Git submodule update
2: Install nginx
./Configure -- prefix =/opt/nginx -- add-module =/opt/software/nginx-gridfs
Make
Make install
3: Configure nginx-gridfs :( reference: https://github.com/rjhunjhunwla/nginx-gridfs-related parameter settings)
Add the following to the nginx. conf file:
Location/video {
Gridfs dbname
Root_collection = fs
Field = filename
Type = string
User = username
Pass = passwd;
Mongo 127.0.0.1: 27017;
}
4: html call display :( http://www.videojs.com/download using video. js)
<Video class = "video-js vjs-default-skin" controls width = "640" height = "264" preload = "auto">
<Source src = "http: // 127.0.0.1/video/filename.mp4" type = 'video/mp4'/>
</Video>