Installing HLS Streaming Media server

Source: Internet
Author: User
Tags xsl

Platform: centos6.5 x86_64 Minimized installation

1 Installing the Rmpforge source

RPM-UVH http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm

Installing the Epel source

RPM-UVH http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

2 Update

Yum Update-y

3 Installing the Associated libraries

Yum install-y automake autoconf make gcc gcc-c++ libtool libvpx bzip2 subversion libjpeg-devel zlib zlib-devel Curl curl- Devel alsa-lib alsa-lib-devel gettext gettext-devel expat expat-devel libogg Theora libtheora-devel xvidcore Xvidcore-dev El Vorbis libvorbis-devel faac-devel lame-devel amrnb-devel opencore-amr-devel amrwb-devel perl-devel git

4 Installing the YASM assembler

wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz

Tar zxvf yasm-1.3.0.tar.gz

CD yasm-1.3.0

./configure

Make && make install


5 Installing the MPlayer encoding Library (64-bit systems only)

wget http://www2.mplayerhq.hu/MPlayer/releases/codecs/essential-amd64-20071007.tar.bz2

Tar xjvf essential-amd64-20071007.tar.bz2

Mkdir-p/usr/local/lib/codecs

CP-RVP essential-amd64-20071007/*/usr/local/lib/codecs/

Vi/etc/ld.so.conf

Add to

/usr/lib

/usr/local/lib


6 Installing x264

wget ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2

Tar jxvf last_stable_x264.tar.bz2

CD x264-snapshot-20150825-2245-stable/(date is your current date, LS see)

./configure--enable-shared--enable-pic

Make && make install


7 Installing LIBVPX

wget http://storage.googleapis.com/downloads.webmproject.org/releases/webm/libvpx-1.4.0.tar.bz2

Tar jxvf libvpx-v1.4.0.tar.bz2

CD libvpx-v1.4.0

./configure--enable-shared--enable-pic

Make && make install


8 Installing Pkgconfig

Curl Http://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz-o pkgconfig.tgz

TAR-ZXF pkgconfig.tgz && CD pkg-config-0.28

./configure--with-internal-glib

Make && make install

Export Pkg_config_path=/usr/local/bin/pkg-config: $PKG _config_path


9 Installing FFmpeg

wget http://ffmpeg.org/releases/ffmpeg-2.7.2.tar.bz2

Tar jxvf ffmpeg-2.7.2.tar.bz2

CD ffmpeg-2.7.2

./configure--ENABLE-GPL--enable-version3--enable-shared--enable-nonfree--enable-postproc--ENABLE-LIBFAAC-- Enable-libmp3lame--enable-libopencore-amrnb--ENABLE-LIBOPENCORE-AMRWB--enable-libtheora--enable-libvorbis-- ENABLE-LIBVPX--enable-libx264

Make && make install



10 Install MEncoder encoder (optional, support convert RMVB to AVI)

Yum install-y mplayer mencoder flvtool2


MENCODER-OAC Help View the audio

MENCODER-OAC Help view the video's



11 Installing Nginx

Preparing the relevant modules

Yum install-y openssl-devel pcre pcre-devel yamdi


12 Mounting support Flv/mp4 playback module

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz


Tar zxvf nginx_mod_h264_streaming-2.2.7.tar.gz


CD nginx_mod_h264_streaming-2.2.7


Modify the source code, comment out 158 lines to 161 lines

VI./src/ngx_http_streaming_module.c

/* TODO:WIN32 */

if (R->zero_in_uri)

// {

return ngx_declined;

// }


13 downloading modules that support the RTMP/HLS protocol

Wget-o Nginx-rtmp-module.zip Https://github.com/arut/nginx-rtmp-module/archive/master.zip

Unzip Nginx-rtmp-module.zip


Download Cache Module

Wget-o Ngx_cache_purge.zip Https://github.com/FRiCKLE/ngx_cache_purge/archive/master.zip

Unzip Ngx_cache_purge.zip


Install the latest Nginx

wget http://nginx.org/download/nginx-1.9.4.tar.gz

Tar zxvf nginx-1.9.4.tar.gz

CD nginx-1.9.4

./configure--user=daemon--group=daemon--prefix=/usr/local/nginx/--add-module=.. /nginx-rtmp-module-master--add-module=. /ngx_cache_purge-master--add-module=. /nginx_mod_h264_streaming-2.2.7--with-http_stub_status_module--with-http_ssl_module--with-http_sub_module-- With-http_gzip_static_module--with-http_flv_module


Make && make install


/usr/local/nginx/sbin/nginx-v to see if the installed modules are correct


Cp/usr/local/nginx/conf/nginx.conf/usr/local/nginx/conf/nginx.conf.bk


Set up a video directory for storage

Mkdir/mnt/media/vod/mnt/media/app/mnt/media/vedio


Vi/usr/local/nginx/conf/nginx.conf

#filename: nginx.conf

#user nobody;

Worker_processes 1;


Error_log Logs/error.log;

#error_log Logs/error.log Notice;

#error_log Logs/error.log Info;

PID Logs/nginx.pid;

Events {

Use Epoll;

Worker_connections 1024;

}


rtmp {

server {

Listen 1935;

Chunk_size 4000;


# Video on Demand

Application VOD {

Play/mnt/media/vod;

}


# HLS

# HLS requires Libavformat & should be configured as a separate

# NGINX module In addition to Nginx-rtmp-module:

#./configure ... –add-module=/path/to/nginx-rtmp-module/hls ...

# for HLS to work, create a directory in Tmpfs (/tmp/app here)

# for the fragments. The directory contents is served via HTTP (see

# http{} section in config)

#

# Incoming Stream must is in H264/aac/mp3. For iPhones use baseline H264

# profiles (see ffmpeg example).

# This example creates RTMP stream from the movie Ready for HLS:

#

# ffmpeg-loglevel Verbose-re-i Movie.avi-vcodec libx264

#-vprofile Baseline-acodec Libmp3lame-ar 44100-ac 1

#-f flv Rtmp://localhost:1935/hls/movie

#

# If you need to transcode live stream use ' exec ' feature.

#

Application HLS {

HLS on;

Hls_path/mnt/media/app;

Hls_fragment 10s;

}

}

}

HTTP {

Include Mime.types;

Default_type Application/octet-stream;

Sendfile on;

Keepalive_timeout 65;

gzip on;

#log format

Log_format access ' $remote _addr– $remote _user [$time _local] "$request"

' $status $body _bytes_sent ' $http _referer '

' "$http _user_agent" $http _x_forwarded_for ';

#定义一个名为addr的limit_zone, size 10M memory to store session

Limit_conn_zone $binary _remote_addr zone=addr:10m;

server {

Listen 8080;

server_name localhost;

# HTTP can be used for accessing RTMP stats

# This URL provides RTMP statistics in XML

Location/stat {

Rtmp_stat all;

Rtmp_stat_stylesheet stat.xsl;

}

location/stat.xsl {

Root/mnt/soft/nginx-rtmp-module-master;

}

Location/control {

Rtmp_control all;

}

Location/{

Root/mnt/soft/nginx-rtmp-module-master/test/rtmp-publisher;

}

}

server {

Listen 80;

server_name localhost;

Location /{

Root/mnt/wwwroot;

Index index.html;

}

Location ~ \.flv$ {

Root/mnt/media/vod;

flv

Limit_conn addr 20;

Limit_rate 200k;

}

Location ~ \.mp4$ {

Root/mnt/media/vod;

mp4;

Limit_conn addr 20;

Limit_rate 200k;

}


Location/hls {

# Serve HLS Fragments

Alias/mnt/media/app;

}


Access_log Logs/nginxflv_access.log access;

}

}

14 Installing the Slicing tool segmenter

git clone https://github.com/johnf/m3u8-segmenter.git


CD m3u8-segmenter/


Gcc-wall-g M3u8-segmenter.c-o Segmenter-lavformat


CP segmenter/usr/bin/

Add Nginx to system service

15 Testing

Upload MP4 file to/mnt/media/video/

Convert MP4 to FLV format

cd/mnt/media/video/

Ffmpeg-i movie1.mp4-y-vcodec libx264-vf scale= "640:-1"-R 15-acodec Libfaac. /vod/movie1.flv

Cd.. /vod

MV movie1.flv movie1-src.flv

Add keyframes to support drag play

Yamdi-i Movie1-src.flv-o movie1.flv


Convert FLV to TS file

Mkdir/mnt/media/app/movie1

Still under the VOD directory

Ffmpeg-y-I movie1.flv-f mpegts-c:v copy-c:a copy-vbsf h264_mp4toannexb/mnt/media/app/movie1/main.ts


Slice

cd/mnt/media/app/movie1/

Segmenter-i main.ts-d 10-p movie1-m movie1.m3u8-u http://YOURSERVERIP/hls/movie1/


Test

Http://YOURSERVERIP/hls/movie1/movie1.m3u8

This article references

http://hdu104.com/294


Installing HLS Streaming Media server

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.