Live streaming with red5 and ffmpeg On Linux

Live streaming with red5 and ffmpeg On Linux





Live Stream





Prerequisite


Hardware


  • High Power server/system.
  • Osprey card or TVCAP (easycap)
  • Good camera
  • High bandwidth.


Software
          
  • Osprey card driver (need to compile)
  • red5 media server with midiDemo plugin
  • java jdk 6
  • ffmpeg



Overview


In our scenario  we take an input from camera and passes it osprey card and osprey card passes this output to ffmpeg and ffmpeg encode the video and passes it to red5 server midi Demo plug in  once plugin receive  this it will pass to web server where  we had coded a html page with fl player which will receive input from red 5 server and play here.




Configuration and setting up server



Installation Of OS


    We had tested this scenario on Debian wheezy latest stable of debian version 7.3.0
we need to install a debian wheezy on server then we have to add couple of repos and packages
on it.


1. we need to add the following repos on /etc/sources.list


deb http://ftp.us.debian.org/debian stable main contrib non-free
deb-src http://ftp.us.debian.org/debian stable main contrib non-free


deb http://ftp.debian.org/debian/ wheezy-updates main contrib
deb-src http://ftp.debian.org/debian/ wheezy-updates main contrib


deb http://security.debian.org/ wheezy/updates main contrib
deb-src http://security.debian.org/ wheezy/updates main contrib


2. apt-get update && apt-get upgrade.


3. need to install the following packages


apt-get install libproc-processtable-perl
apt-get install linux-headers-`uname -r` linux-source
apt-get install tvtime quilt


NOTE :- we have to select PAL and radio frequency as other while installing tvtime package.








Compiling the driver for OSPREY card 260e


Once we have install all packages we need to compile the driver for osprey card you will find the detail tut here
 
here  i will post some steps of it for compiling:-


1. mkdir /data/osprey && cd /data/osprey
3. tar -zxvf 460e-dev-20120531-112107.tgz
4. cd 260e/media_build
5.make clean
6.make distclean
7.make cx23885config
8.make -j3
9. make install
10.Remove the cx23885 driver from auto-loading during system startup  sudo vi /etc/modprobe.d/blacklist.conf, add to the end of the file the line "blacklist cx23885"


This will compile and install the driver  now we have to shutdown the system and install the hardware on AGP slot. once this done, power on server and navigate to directory where we compile the driver


11 cd /data/260e


here you find the 2 scripts load.sh and unload.sh for loading driver use load.sh
12 sh load.sh
13 ehco $?
    
once your command successfully executed you are able to view the device on /dev


14 ll /dev/video0


installing red5 and ffmpeg on debian.
installing red5 server and ffmpeg is really easy we just have to download and extract it run it and ffmpeg is available at aptitude. before installing red 5 you have to ensure that you are running java jdk 6


Ensure that you are running java version 6 by


kaustubh@kaustubh-pc:~$ java -version
Output is like
java version "1.6.0_27"
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
kaustubh@kaustubh-pc:~$



Once you are sure that you have java 6 follow the steps for installing red5



  1. Download the red5 media server from here . and copy to data
  2. mkdir /data/red5 (make directory for red5)
  3. tar-zxvf red5-0.9.RC2.tar.gz
  4. cd red5
  5. sh red5.sh (this will start red5 server on server at localhost:5080)



once you done this all without error you will found that installer service has been create
and you can navigate to localhost:5080 via any browser that you like :)


Now we will install ffmpeg then we will move to next session for configuration.


For installing ffmpeg just run following commands


# sudo aptitude install ffmpeg


It will install all the modules required by ffmpeg.







Configuration of streaming.


Preparing our red5 for Line streaming .


Ensuring that red5 server working properly


Once you started red 5 server it will look like


The we have to navigate to localhost:5080 and navigate to install link which will look like this


here we have to install some  plugins
  1. midiDemo
  2. oflaDemo
  3. SOSample
  4. echo
Once install we will check whether our red5 streaming server works properly or any isssue is their by SOSample plugin




After installing login to localhost:5080 and click on demo this time once you landed on demo.
Click on shared ball object and open one more side by side and click on connect which looks like.


Now drag any one of them Both will be moved if it moves then its all fine ;).


Now again navigate to localhost:5080 and open Publisher plugin which looks like this




Here we have to configure Most important part of streaming server parameters like stream and all.


stream : the name of stream which you want
server :- leave it default
location :- rtmp://localhost/midiDemo  (Here we have to change don't give any custom name should  be  same)


Now click on connect it will show connection success  like this
15:16:49:649 - Using Google Pepper Flash Player 11,8,800,170
15:16:58:317 - Connecting to rtmp://localhost/midiDemo
15:16:58:359 - NetConnection.Connect.Success


Now our red5 server is ready for receiving the rtmp input and able to broadcast to flash :)


We have to capture camera and encode the video and we have to send this to our html page which we design later.


Now we have to start encoding and passing it to red 5 using ffmpeg by a simple command

#ffmpeg -f video4linux2 -i /dev/video0 -s 320x480 -f flv -f flv rtmp://your-local-ip/midiDemo/test

This will look like this

Now we have done everything now we just have to make web page and start our web server



Here i have created  a sample setup just download the file and copy all files to your document root




and


Then open the index.html and change the net connection url ip to your ip and here we go



Start your web server and you will find the player streaming live


Which looks like This. Happy streaming



Comments

  1. thanks for this tutorial, however:
    1) the pictures are all missing, I see blank white squares
    2) there's nothing about securing the red5 input source from hijackers, which means anyone who knows the rtmp url can upstream their own video and broadcast it on your site.
    or did I miss something?

    ReplyDelete
  2. The PSL Fever is at its Peak, With Such Hype of Pakistan Super League there is nothing better to watch PSL Live Streaming For free on your smartphones.

    Watch PSL Live Streaming 2020
    Watch PSL 2020 Live Streaming

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Its more than just cricket, it’s bigger than just a match. Experience the love for sports and feel the cricket-rivalry of cities as PSL 2021 unfolds

    Fans around the world are excited to have their favourite cricket league back as PSL 6 is starting from 20th February 2021. Cricket fever runs deep within the Pakistani nation and it would be fair to say that the PSL craze clearly reflects through the eyes of millions of fans as they wait each year for PSL. Pakistan Super League is one of the most awaited cricket leagues around the world and is known for its fierce bowling, low-score thrillers, and unmatched competition. Watch PSL Live

    ReplyDelete

Post a Comment