Announcement Announcement Module
Collapse
No announcement yet.
Live Video Streaming using ffmpeg and Red5 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Live Video Streaming using ffmpeg and Red5

    I would like to share the steps for Live streaming of video through Linux, Live streaming allows us to capture the videos from IP cameras and display it into our web browser, the streaming process is executing in our server which is through an application called RED 5. RED5 is an open source application developed in Java, which is to convert a RTSP link to a RTMP link. RTSP is the link direclty from camera and RTMP is the streaming output displays it in our web browser . A RTSP streaming video can be displayed in a webpage using Javascript.

    First step of video streaming is to install RED 5 in our server, RED 5 is concerned about identifying RTSP and RTMP

    STEP 1 - INSTALL JAVA (Skip the step if you already installed the JAVA)
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Download latest stable version of Java from http://www.oracle.com/technetwork/ja...s-1880260.html.
    For 64 bit processors -
    # cd /opt/ # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-x64.tar.gz"

    Unzip the TAR file
    ------------------------------------
    -

    # tar xzf jdk-7u71-linux-x64.tar.gz

    Install JAVA using alternatives
    ----------------------------------------------------


    # cd /opt/jdk1.7.0_71/ # alternatives --install /usr/bin/java java /opt/jdk1.7.0_71/bin/java 2 # alternatives --config java
    There are 4 programs which provide 'java'. Selection Command ----------------------------------------------- * 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java + 2 /opt/jdk1.7.0_60/bin/java 3 /opt/jdk1.7.0_67/bin/java 4 /opt/jdk1.7.0_71/bin/java Enter to keep the current selection[+], or type selection number: 4 [Press Enter]


    Setup javac and jar commands path using alternatives
    ---------------------------------------------------------------------------------

    # alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_71/bin/jar 2 # alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_71/bin/javac 2 # alternatives --set jar /opt/jdk1.7.0_71/bin/jar # alternatives --set javac /opt/jdk1.7.0_71/bin/javac

    Check JAVA VERSION
    ----------------------------------------------------------------------------------

    # java -version java version "1.7.0_71" Java(TM) SE Runtime Environment (build 1.7.0_71-b14) Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)


    Setup Environment variables
    ----------------------------------------------------------------------------------

    Setup JAVA_HOME Variable
    # export JAVA_HOME=/opt/jdk1.7.0_71 Setup JRE_HOME Variable
    # export JRE_HOME=/opt/jdk1.7.0_71/jre Setup PATH Variable
    # export PATH=$PATH:/opt/jdk1.7.0_71/bin:/opt/jdk1.7.0_71/jre/bin JAVA Installation finished


    STEP 2 - INSTALL RED5
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Download and Extract RED 5
    ---------------------------------------------------------------------------------

    # cd /opt/ # wget http://www.red5.org/downloads/red5/1...5-1.0.1.tar.gz # tar xzf red5-1.0.1.tar.gz # mv red5-server-1.0/ red5

    Start RED 5
    ---------------------------------------------------------------------------------

    # cd /opt/red5 # ./red5.sh

    Access RED 5 Interface
    ---------------------------------------------------------------------------------

    URL: http://localhost:5080

    Install DEMO Apps in RED 5
    ---------------------------------------------------------------------------------

    http://localhost:5080/installer/

    Access DEMO apps in RED 5
    ---------------------------------------------------------------------------------

    http://localhost:5080/demos/

    If you are getting any host name error add a hostname for your server in /etc/hosts file with your server's IP as follows
    <ip address> <host name>
    127.0.0.1 Hostname



    STEP 3 - INSTALL FFMPEG
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Before installing ffmpeg please update you rpm file to get stable and latest release of ffmpeg, Otherwise you may loose frames while streaming.

    yum install ffmpeg-devel ffmpeg
    yum install ffmpeg-devel ffmpeg
    yum -y --enablerepo=atrpms install ffmpeg
    yum -y --enablerepo=atrpms install ffmpeg

    Confirm you ffmpeg installing using following command
    -----------------------------------------------------------------------------------------
    ffmpeg -version

    STEP 4 - STREAMING RTSP TO RTMP
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Use the following command for live streaming and it will starts stream your RTSP link to RTMP

    ffmpeg -i "rtsp://streaminglink/url" -f flv -r 25 -s 640x480 -an "rtmp://localhost/livestream"

    STEP 5 - DISPLAY RTMP STREAMING IN A WEB BROWSER
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    Add the following javascript code in a webpage and save it as stream.html

    <script type="text/javascript" src="/opt/red5/umsplayer.js" charset="utf-8"></script>

    <script type="text/javascript">
    embedPlayer('player-container', { flashvars :
    { 'rtmp' : 'rtmp://localhost/livestream',
    'autoplay' : true,
    'showMetadata': true,
    'showLiveCaption' : true,
    'livelabelshowbg': false, 'showErrorInPlayer' : true },
    size : { width: 640, height: 480 },
    playerStyle : 'quick' });
    </script>


    Access the stream.html from your webrowser and it will start streaming your RTSP link.
    Last edited by letom; 5th December 2014, 07:23 PM.
Working...
X