Build a FLV Video Server in nginx and support video drag progress bar playback

Source: Internet
Author: User
Tags flv file

Currently, due to the popularity of flash, most micro-video websites on the network use the FLV format to play videos.

There are two ways to play videos on the Internet. One is the file method, that is, accessing video files through HTTP. The disadvantage of this method is that it cannot be played from a specific frame; another method is to use a dedicated Streaming Media Server. The disadvantage of this method is to build a complex Streaming Media Server. However, there is now a solution that combines the advantages of the above two methods, namely, using HTTP to implement pseudo-streaming media. This article describes such a solution.

First, configure the nginx service to support the FLV module function.

(1) Check whether your nginx supports the FLV function module.

[Root @ localhost ~] #/Usr/local/nginx/sbin/nginx-V // view nginx Service Support

Result:

Nginx version: nginx/0.8.24

Built by GCC 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)

Configure arguments: -- prefix =/usr/local/nginx -- with-http_flv_module -- with-http_gzip_static_module -- with-http_stub_status_module

Analysis: My nginx version 0.8.24 and http_flv_module have been enabled to support the FLV service.

(2) install the nginx server that supports the FLV module:

# Tar zxvf nginx-0.8.24.tar.gz

# Cd nginx-0.8.24

#./Configure -- prefix =/usr/local/nginx -- with-http_flv_module -- with-http_gzip_static_module -- with-http_stub_status_module // enable FLV Module

# Make & make install

#/Usr/local/nginx/sbin/nginx // start nginx

(3) nginx server configuration (nginx. conf file)

Server

{

Listen 80;

SERVER_NAME localhost;

Charset UTF-8;

Location /{

Root HTML;

Index index. php index.html index.htm;

}

Location ~ \. FLV {

FLV;

Limit_rate_after 10 m;

Limit_conn one 1;

Limit_rate 85 K;

}

}

Use location to direct the. FLV file to the FLV module.

The limit_rate is used for speed limit. When the FLV video is downloaded for more than 10 MB, the speed limit is up to 85 KB. Only one process can be enabled, that is, the cache can be played first, download it later.

(4) install a player that supports FLV drag and drop progress bars

The above three steps are to install a player that supports the nginx service to support the FLV function. Now you need to support the FLV drag and drop progress bar.

You need a player that can play FLV videos. Obviously, it needs to be embedded into webpages. Currently, it is quite popular, and a fully functional flvplayer is jw flv Media Player (also known as secure player ). Its URL is:

Http://www.longtailvideo.com/players/jw-flv-player/

This player supports adding advertisements and video programs to videos,

The downloaded package contains a wide range of instances and usage methods,

Put the player.swf(if There Is A viralplug, then player-viral.swf) in your website. This is the player that provides video playback. Do not use other files in the package.

Next, embed the player into your video play webpage:

Directly embed data using the object/embed code:

<Embed

Type = "application/X-Shockwave-flash"

Id = "player2"

Name = "player2"

Src = "player.swf"

Width = "328"

Height = "200"

AllowScriptAccess = "always"

Allowfullscreen = "true"

Flashvars = "file = http: // 192.168.40.135/test. FLV & image = http: // 192.168.40.135/preview.jpg & autostart = false & type = http & streamer = start"

> </Embed>

File: "video. FLV", // FLV video address

Type: "HTTP", // data type. This document is based on the http mode.

Image: "preview.jpg", // preview image before playing

Autostart: "false", // whether to play automatically

Streamer: "Start", // The parameter is "start". This parameter is used to pass to the server to start playing from a specific key frame. Therefore, nginx supports compiling the FLV module ..

Add a key frame to a sequence

If a FLV video can be dragged to a specific point for playback, The FLV needs to have key frame information in its metadata. If you do not have this information when making a FLV video, you cannot drag and drop the video. You can use yamdi to add key frame information to your video:

Installation:

1 [root @ localhost ~] # Wget http://sourceforge.net/projects/yamdi/files/yamdi/1.4/yamdi-1.4.tar.gz/download

2 [root @ localhost ~] # Tar zxvf yamdi-1.4.tar.gz

3 [root @ localhost ~] # Cd yamdi-1.4/

4 [root @ localhost yamdi-1.4] # Make & make install

Usage:

Yamdi-I source. FLV-O DeST. FLV // The output video of the original video.

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.