Use Nginx + FFmpeg to build an HLS live video transcoding Server

Source: Internet
Author: User

Use Nginx + FFmpeg to build an HLS live video transcoding Server

Objective: To enable Nginx to support Rtmp streaming, HLS distribution, and FFmpeg transcoding multi-bit rate.

I. Preparations
Module: nginx-rtmp-module-master (rtmp protocol supported)
:
Http://nginx.org
Https://github.com/arut/nginx-rtmp-module

1. Install the dependency package:
# Yum-y install gcc glibc-devel make nasm pkgconfig lib-devel openssl-devel expat-devel gettext-devel libtool mhash. x86_64 perl-Digest-SHA1.x86_64 gcc-c ++

2. Install the git tool:
# Mkdir soft-source
# Cd soft-source
# Wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
# Tar xzvf git-latest.tar.gz
# Cd git-2013-02-04
# Autoconf
#./Configure
# Make & make install
# Git -- version
Git version 1.8.1.GIT
# Cd ..

[Error handling]

If the git-latest.tar.gz size is 0, download the git-latest-tar.xz

Then xz-d git-latest.tar.xzis decompressed as .tar.

Tar xvf git-latest.tar

3. Install ffmpeg and its dependent packages:
+++ ++ Yasm ++
# Wget http://www.tortall.net/projects/yasm/releases/yasm-1.2.0.tar.gz
# Tar xzvf yasm-1.2.0.tar.gz
# Cd yasm-1.2.0
#./Configure
# Make
# Make install
# Cd ..
++ X264 ++
# Git clone git: // git.videolan.org/x264
# Cd x264
#./Configure -- enable-shared
# Make
# Make install
# Cd ..

++ LAME ++
# Wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
# Tar xzvf lame-3.99.5.tar.gz
# Cd lame-3.99.5
#./Configure -- enable-nasm
# Make
# Make install
# Cd ..
++ Libogg ++
# Wget http://downloads.xiph.org/releases/ogg/libogg-1.3.0.tar.gz
# Tar xzvf libogg-1.3.0.tar.gz
# Cd libogg-1.3.0
#./Configure
# Make
# Make install
# Cd ..
++ Libvorbis ++
# Wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.3.tar.gz
# Tar xzvf libvorbis-1.3.3.tar.gz
# Cd libvorbis-1.3.3
#./Configure
# Make
# Make install
# Cd ..
++ Libvpx ++
# Git clone http://git.chromium.org/webm/libvpx.git
# Cd libvpx
#./Configure -- enable-shared
# Make
# Make install
# Cd ..
++ FAAD2 ++
# Wget http://downloads.sourceforge.net/project/faac/faad2-src/faad2-2.7/faad2-2.7.tar.gz
# Tar zxvf faad2-2.7.tar.gz
# Cd faad2-2.7
#./Configure
# Make
# Make install
# Cd ..
++ FAAC ++
# Wget http://downloads.sourceforge.net/project/faac/faac-src/faac-1.28/faac-1.28.tar.gz
# Tar zxvf faac-1.28.tar.gz
# Cd faac-1.28
#./Configure
# Make
# Make install
# Cd ..

[Error handling]

An error occurred while compiling FAAC-1.28:

Mpeg4ip. h: 126: error: new declaration 'Char * strcasestr (const char *, const char *)'

Solution:

Modify the object mpeg4ip. h from row 3 to row 3.
Before modification:
# Ifdef _ cplusplus
Extern "C "{
# Endif
Char * strcasestr (const char * haystack, const char * needle );
# Ifdef _ cplusplus
}
# Endif

After modification:
# Ifdef _ cplusplus
Extern "C ++ "{
# Endif
Const char * strcasestr (const char * haystack, const char * needle );
# Ifdef _ cplusplus
}
# Endif


++ Xvid ++
# Wget http://downloads.xvid.org/downloads/xvidcore-1.3.2.tar.gz
# Tar zxvf xvidcore-1.3.2.tar.gz
# Cd xvidcore/build/generic
#./Configure
# Make
# Make install
Cd ../../../


++ Ffmpeg ++
# Git clone git: // source.ffmpeg.org/ffmpeg
# Cd ffmpeg
#. /Configure -- prefix =/opt/ffmpeg/-- enable-version3 -- enable-libvpx -- enable-libfaac -- enable-libmp3lame -- enable-libvorbis -- enable-libx264 -- enable-libxvid -- enable-shared -- enable-gpl -- enable-postproc -- enable-nonfree -- enable-avfilter -- enable-pthreads
# Make & make install
# Cd ..
[Error handling]

If the message "libvpx decoder version must be> 255.0.91,1" is displayed, download libvpx-v1.1.0.tar. bz from baidusearch.

Bzip2-d libvpx-v1.1.0.tar.bz2

Tar xvf libvpx-v1.1.0.tar.bz2

Cd libvpx-v1.1.0

./Configure -- enable-shared -- enable-vp8

Make

Make install


Modify/etc/ld. so. conf as follows:
Include ld. so. conf. d/*. conf
/Lib
/Lib64
/Usr/lib
/Usr/lib64
/Usr/local/lib
/Usr/local/lib64
/Opt/ffmpeg/lib
# Ldconfig

[Description]

The dynamic loader relies on two files-/etc/ld. so. conf and/etc/ld. so. cache to find the shared library.

After the installation is complete, ffmpeg is located in the/opt/ffmpeg/bin directory.

Compile FFmpeg in Linux to download and compile the source file

Linux compiling and upgrading FFmpeg

Install FFMPEG on CentOS 5.6

Install FFmpeg in Ubuntu

Compile ffmpeg in Ubuntu 12.04

Install FFmpeg 2.2.2 In PPA in Ubuntu 14.04

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.