Sunday, February 25, 2018

crtmpserver, RTMP/RTSP streaming server

*** info
streaming server ip: 192.168.22.5
- video file named newtest.flv


1- install packages
$ sudo apt-get install crtmpserver apache2 flvstreamer

2- start server
$ sudo /etc/init.d/crtmpserver restart
$ sudo /etc/init.d/apache2 restart

3- create a mediafile directory
$ sudo mkdir /var/lib/crtmpserver/mediaFolder -p 

- update your flv/mp4 file to that directory

4- download jarisplayer
https://github.com/jegoyalu/jarisplayer/archive/master.zip

then extract to /var/ww/html/stream

5- edit index.html off jarisplayer in /var/ww/html/stream/bin/index.html
 as below
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <title>Jaris FLV Player</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />
    <meta name="description" content="" />
    <meta name="keywords" content="" />

    <script src="js/swfobject.js" type="text/javascript"></script>
    <script type="text/javascript">
        var flashvarsVideo = {
         // source: "http://jaris.sourceforge.net/files/jaris-intro.flv",
          source: "newtest.flv",
            type: "video",
            streamtype: "file",
            server: "",//Used for rtmp streams
            duration: "52",
            poster: "http://jaris.sourceforge.net/images/poster.png",
            autostart: "false",
            logo: "http://jaris.sourceforge.net/images/logo.png",
            logoposition: "top left",
            logoalpha: "30",
            logowidth: "130",
            logolink: "http://jaris.sourceforge.net",
            hardwarescaling: "false",
            darkcolor: "000000",
            brightcolor: "4c4c4c",
            controlcolor: "FFFFFF",
            hovercolor: "67A8C1"
        };
        var flashvarsVideoNewControls = {
//            source: "http://jaris.sourceforge.net/files/jaris-intro.flv",
            type: "video",
            streamtype: "rtmp",
                      server: "rtmp://192.168.22.5:1935/flvplayback/",
                   //server: "rtmp://192.168.22.5:1935/live/",
        //source:"test",
        //source:"newtest.flv",

  //source:"newtest",
        //source:"test1",
        //source:"gigi",
            duration: "52",
            poster: "http://jaris.sourceforge.net/images/poster.png",
            autostart: "false",
            logo: "http://jaris.sourceforge.net/images/logo.png",
            logoposition: "top left",
            logoalpha: "30",
            logowidth: "130",
            logolink: "http://jaris.sourceforge.net",
            hardwarescaling: "false",
            darkcolor: "000000",
            brightcolor: "4c4c4c",
            controlcolor: "FFFFFF",
            hovercolor: "67A8C1",
            controltype: 1
        };
        var flashvarsAudio = {
            source: "http://jaris.sourceforge.net/files/audio.mp3",
            type: "audio",
            streamtype: "file",
            server: "",//Used for rtmp streams
            duration: "00:04:25",
            poster: "http://jaris.sourceforge.net/images/poster.png",
            autostart: "false",
            logo: "http://jaris.sourceforge.net/images/logo.png",
            logoposition: "top left",
            logoalpha: "30",
            logowidth: "130",
            logolink: "http://jaris.sourceforge.net",
            hardwarescaling: "false",
            darkcolor: "D3D3D3",
            brightcolor: "FFFFFF",
            controlcolor: "000000",
            hovercolor: "FF0000"
        };
        var params = {
            menu: "false",
            scale: "noScale",
            allowFullscreen: "true",
            allowScriptAccess: "always",
            bgcolor: "#000000",
            quality: "high",
            wmode: "opaque"
        };
        var attributes = {
            id:"JarisFLVPlayer"
        };
        swfobject.embedSWF("JarisFLVPlayer.swf", "altContentOne", "576px", "360px", "10.0.0", "expressInstall.swf", flashvarsVideo, params, attributes);
        swfobject.embedSWF("JarisFLVPlayer.swf", "altContentOneNewControls", "576px", "360px", "10.0.0", "expressInstall.swf", flashvarsVideoNewControls, params, attributes);
        swfobject.embedSWF("JarisFLVPlayer.swf", "altContentTwo", "576px", "360px", "10.0.0", "expressInstall.swf", flashvarsAudio, params, attributes);
    </script>
    <style>
        html, body { height:100%; }
        body { margin:0; }
    </style>
</head>
<body>
<br />
    <center>
    <h1>Video Example</h1>
    <div id="altContentOne">
        <h1>Jaris FLV Player</h1>
        <p>Alternative content</p>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img
            src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
            alt="Get Adobe Flash player" /></a></p>
    </div>

    <br /><br />

    <h1>Video Example with New Controls</h1>
    <div id="altContentOneNewControls">
        <h1>Jaris FLV Player</h1>
        <p>Alternative content</p>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img
            src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
            alt="Get Adobe Flash player" /></a></p>
    </div>

    <br /><br />

    <h1>Audio Example</h1>
    <div id="altContentTwo">
        <h1>Jaris FLV Player</h1>
        <p>Alternative content</p>
        <p><a href="http://www.adobe.com/go/getflashplayer"><img
            src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
            alt="Get Adobe Flash player" /></a></p>
    </div>
    </center>
</body>
</html>




6- to access it use url
http://192.168.22.5/stream/bin/

or with vlc use url
$ vlc rtmp://192.168.22.5:1935/flvplayback/newtest.flv
$ vlc rtmp://192.168.22.5:1935/live/newtest.flv

or with flvstreamer
$ flvstreamer --rtmp rtmp://192.168.22.5:1935/flvplayback/newtest.flv | mp  -




7- we can also use ffmpeg to do the inboundflv 
$ ffmpeg -i newtest.flv -vcodec libx264 -f flv -metadata streamName=test1 "tcp://192.168.22.5:6666"

so we need to change our index.html on source to
source:"test1",


- below to stream webcam
$ ffmpeg -f video4linux2 -s 320x240 -i /dev/video0 -f flv -s qvga -b 750000 -ar 11025 -metadata streamName=test1 "tcp://192.168.22.5:6666"

No comments:

Post a Comment