Results 1 to 1 of 1

Thread: How to stream from an RTSP source?

  1. #1
    Join Date
    Apr 2013
    Beans
    1

    How to stream from an RTSP source?

    I didnt know where to put it so I put it here .

    I recently did an streaming service for an enterprise and I've done a tutorial for all of you out there who want to stream.

    So here we go:


    Requirements:


    • RTSP source (source that provides an RTSP link)
    • 2 computers (A server and a client, in our example we used: For the client: Ubuntu 13.04 and for the Server: Ubuntu Server 12.10)
    • RTMP server (crtmpserver)
    • JW Player (By using JW Player we will be able to watch the stream on our own website)
    • Apache2 (we need this to run our website, we can download it, on the server, by using the command: sudo apt-get install apache2)
    • VLC (Installed on the client, remember that you cant use VLC if you are as the user “root“) (We will also need this to do an HLS)

    How to do an RTSP source?

    We have two ways to do it:

    Long Way


    For this one you will only need:
    • An Ubuntu client, such as ours: Ubuntu 13.04
    • VLC Installed on the client (remember the annotations above)

    Steps


    • Open to VLC
    • Press Shift + Ctrl + O
    • Press ADD
    • Add a file
    • Go to show more options (It is located at the bottom part)
    • Go to the Play button and click the arrow button (Located right next to it)
    • Go to Stream (Alt + S)
    • Go to “Destination setup”
    • Uncheck “Activate Transcoding”
    • Go to “New Destination” and select RTSP
    • Go to ADD
    • Replace the path for: /stream
    • Click next
    • Check “Stream all elementary streams” and modify “Time-To-Live” to 128
    • Start streaming

    Annotation: The RTSP will be something like this: rtsp://our_ip:8554/stream

    Short Way


    For this one you will only need:
    • VLC installed (remember not to run it as “root“).
    • A file that you want to stream

    Steps

    Open a new terminal and copy paste this (remember to change whatever is necessary):cvlc file.format :sout=#rtp{sdp=rtsp://:8554/stream} :sout-all :ttl=128sout-keep

    Steps to stream the RTSP source


    First of all, you will need an RTSP source, for this example, we will be using this one:rtsp://apasfwl.apa.at:80/orf1_q6a/orf.sdp (German Television)

    Next step is to install on the Server an RTMP server, for this example we will be using
    crtmpserver.

    How to install crtmpserver?


    As every software on linux we will install CRTMPServer by using the command:sudo apt-get install crtmpserverConfiguration steps

    When the installation is over, we will check the status of the server by doing:sudo service crtmpserver statusIf the server is not started you can start it by doing.sudo service crtmpserver startOnce we have the service started, we will be heading towards the file by using:nano /etc/crtmpserver/crtmpserver.luaWhen you get inside of it you will see this line:

    externalStreams =
    {
    --[[
    {
    uri="rtsp://fms20.mediadirect.ro/live2/realitatea/realitatea",
    localStreamName="rtsp_test",
    forceTcp=true
    },
    {
    uri="rtmp://edge01.fms.dutchview.nl/botr/bunny",
    localStreamName="rtmp_test",
    swfUrl="http://www.example.com/example.swf";
    pageUrl="http://www.example.com/";
    emulateUserAgent="MAC 10,1,82,76",
    }]]--

    You can either remove the annotations or create a new uri as we will do:
    On our example we are using rtsp://apasfwl.apa.at:80/orf1_q6a/orf.sdp so we will create a new uri like this:

    {
    uri="rtsp://apasfwl.apa.at:80/orf1_q6a/orf.sdp",
    localStreamName="stream"
    },

    Lets explain the fields

    • Uri = The RTSP that we provided at the beginning, in our example: rtsp://apasfwl.apa.at:80/orf1_q6a/orf.sdp
    • localStreamName = The link that we will provide to the viewers, for example: http://our_ip/live/stream


    After that you must restart the server and check if everything is alright by using the command:
    sudo service crtmpserver restartAnd checking if it is started by using:sudo service crtmpserver status


    Installing Apache and testing JW Player


    Once you have Apache installed on your server, which will be installed at /var/www, we will dowload JW Player by doing:

    On the client




    On the server


    • cd /var/www
    • sudo unzip jwplayer-3242.zip
    • nano index.html (This is our website) (You will find something like, It works!) Erase all the content and copy paste this:

    <html>

    <head>
    <script src="http://jwpsrv.com/library/mAx4MKWXEeKuhCIACpYGxA.js"></script>




    </head>


    <body><h1>It works!!!</h1>
    <p>This is the default web page for this server.</p>
    <p>The web server software is running but no content has been added, yet.</p>



    <div id='my-video'>
    <script type='text/javascript'>
    jwplayer('my-video').setup({
    file: 'rtmp://our_ip/live/stream',
    image: 'img',
    width: '480',
    height: '270',

    });
    </script>
    </div>




    </body>



    </html>

    Explanation

    Pay attention to the line:file: 'rtmp://our_ip/live/stream'As you must use replace “our_ip” by the ip of your server.By following this steps you should be able to watch your stream on the following path: 10.34.2.125 http://yourip/index.htmlAfter testing our stream we will do it compatible with mobile devices.Steps for doing an HLS


    • Add to your index.html file the following line (before </body>):

    <video autoplay loop controls>
    <source src="http://our_ip/stream.m3u8" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'/>
    </video>

    • Open a new terminal and use the following command (pay attention about what you must replace):

    vlc -v -I "dummy" rtmp://our_ip/live/stream :sout="#transcode{vcodec=h264,vb=100, venc=x264{aud,profile=baseline,level=30,keyint=30, ref=1}, aenc=ffmpeg{aac-profile=low},acodec=mp4a,ab=32,channels=1,samplera te=8000} :std{access=livehttp{seglen=2,delsegs=true,numsegs =2, index=/var/www/stream.m3u8, index-url=http://our_ip/stream-########.ts}, mux=ts{use-key-frames}, dst=/var/www/stream-########.ts}"

    After that you will be able to watch your stream via mobile devices, such as:

    • iOS Devices
    • Android Devices (This functionality only worked on Google Chrome).

    Last edited by lluuuuuK; April 19th, 2013 at 07:26 AM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •