Example of setting up a flv and mp4 streaming media server using nginx

Source: Internet
Author: User

Prepare software:

Nginx-1.6.0.tar.gz
Yamdi-1.9.tar.gz

Yamdi is a progressive stream support module that captures key frames of video resources to achieve random drag during playback.

Download Address: http://ncu.dl.sourceforge.net/project/yamdi/yamdi/1.9/yamdi-1.9.tar.gz

Flv videos can be published over http or rtmp. Http is used here.

Install nginx and mp4 support modules and flv modules:

Nginx support mp4 module download address: http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

Download and decompress the package.

Install the compiling environment:


[Root @ localhost nginx-1.6.0] # yum install-y zlib-devel pcre-devel
[Root @ localhost nginx-1.6.0] # useradd-s/sbin/nologin www
[Root @ localhost nginx-1.6.0] #. /configure -- prefix =/usr/local/nginx -- add-module = .. /nginx_mod_h264_streaming-2.2.7 -- with-http_ssl_module -- user = www -- group = www -- with-http_flv_module -- with-http_stub_status_module
[Root @ localhost nginx-1.6.0] # make & make install
Make-f objs/Makefile
Make [1]: Entering directory '/root/nginx-1.6.0 & prime;
Cc-c-pipe-O-W-Wall-Wpointer-arith-Wno-unused-parameter-Werror-g-D_LARGEFILE_SOURCE-DBUILDING_NGINX-I src/core-I src/event- I src/event/modules-I src/OS/unix-I objs-I src/http/modules-I src/mail \
-O objs/addon/src/ngx_http_h1__streaming_module.o \
../Nginx_mod_h264_streaming-2.2.7/src/ngx_http_h1__streaming_module.c
In file sorted ded from ../nginx_mod_h264_streaming-2.2.7/src/ngx_http_h1__streaming_module.c: 2:
../Nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: In function 'ngx _ streaming_handler ':
../Nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c: 158: error: 'ngx _ http_request_t 'has no member named 'zero _ in_uri'
Make [1]: *** [objs/addon/src/ngx_http_h1__streaming_module.o] Error 1
Make [1]: Leaving directory '/root/nginx-1.6.0 & prime;
Make: *** [build] Error 2

An error occurs. Solution:

Edit/root/nginx_mod_h264_streaming-2.2.7/src/ngx_http_streaming_module.c

[Root @ localhost src] # vim ngx_http_streaming_module.c

Comment out:
/* TODO: Win32 */
If (r-> zero_in_uri)
{
Return NGX_DECLINED;
}

Make again.

Nginx configuration file:

[Root @ localhost nginx-1.6.0] # grep-v "#"/usr/local/nginx/conf/nginx. conf | grep-v "^ $"

Worker_processes 1;
Events {
Worker_connections 1024;
}
Http {
Include mime. types;
Default_type application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
Server {
Listen 80;
Server_name localhost;
Root/usr/local/nginx/html;

Location ~ \. Flv {
Flv;
}

Location ~ \. Mp4 $ {
Mp4;
}
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
}
}

Create two video folders:/usr/local/nginx/html/flv,/usr/local/nginx/html/mp4 to store the video files.

Install yamdi to achieve the drag effect:

[Root @ localhost yamdi-1.9] # make & make install # Two Steps

Add frames to a video:

[Root @ localhost flv] # yamdi-I 1.flv-o test. flv # add the key frame output to 1. flv as test. flv.

Find a Flash Player, download address: http://chinaapp-wordpress.stor.sinaapp.com/uploads/2013/08/player.swf recommended wget download.
Test:
Browser access: http: // 192.168.0.172/player.swf? Type = http & file = flv/test. flv

192.168.0.172 # server IP address
Player.swf # Flash Player program
Http # publish via http
Flv # is the path
Test. flv # is a video file.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.