evanphx / RTSPtoWeb

RTSP Stream to WebBrowser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RTSPtoWeb share you ip camera to world!

RTSP Stream to WebBrowser MSE or WebRTC or HLS, full native! not use ffmpeg or gstreamer

Table of Contents

Download Source

  1. Download source
    $ git clone https://github.com/deepch/RTSPtoWeb  
  2. CD to Directory
     $ cd RTSPtoWeb/
  3. Test Run
     $ GO111MODULE=on go run *.go
  4. Open Browser
    open web browser http://127.0.0.1:8083 work chrome, safari, firefox

Stream mode

on_demand true - receive video from source only has viewer

on_demand false - receive video from source any time

you can set mode use config "on_demand": true or "on_demand": false

Configuration

###Options

####Server section's

debug         - enable debug output
log_level     - log level
http_debug    - debug http api server
http_login    - http auth login
http_password - http auth password
http_port     - http server port
rtsp_port     - rtsp server port

####Stream section's

name          - stream name

####Stream section's

name          - channel name
url           - channel rtsp url
on_demand     - stream mode static (run any time) or ondaemand (run only has viewers)
debug         - enable debug output (RTSP client)
status        - default stream status

example

{
  "server": {
    "debug": true,
    "log_level": "info",
    "http_demo": true,
    "http_debug": false,
    "http_login": "demo",
    "http_password": "demo",
    "http_port": ":8083",
    "rtsp_port": ":5541"
  },
  "streams": {
    "demo1": {
      "name": "test video stream 1",
      "channels": {
        "0": {
          "name": "ch1",
          "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
          "on_demand": true,
          "debug": false,
          "status": 0
        },
        "1": {
          "name": "ch2",
          "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
          "on_demand": true,
          "debug": false,
          "status": 0
        }
      }
    },
    "demo2": {
      "name": "test video stream 2",
      "channels": {
        "0": {
          "name": "ch1",
          "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
          "on_demand": true,
          "debug": false,
          "status": 0
        },
        "1": {
          "name": "ch2",
          "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
          "on_demand": true,
          "debug": false,
          "status": 0
        }
      }
    }
  }
}

Command-Line Arguments

######Use help show arg

./RTSPtoWeb --help

######Response

Usage of ./RTSPtoWeb:
  -config string
        config patch (/etc/server/config.json or config.json) (default "config.json")
  -debug
        set debug mode (default true)

##API documentation

Streams List

Query
GET /streams

curl http://demo:demo@127.0.0.1:8083/streams
Response
{
    "status": 1,
    "payload": {
        "demo1": {
            "name": "test video",
            "channels": {
                "0": {
                    "name": "ch1",
                    "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                    "on_demand": true,
                    "debug": false,
                    "status": 0
                },
                "1": {
                    "name": "ch2",
                    "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                    "on_demand": true,
                    "debug": false,
                    "status": 0
                }
            }
        },
        "demo2": {
            "name": "test video",
            "channels": {
                "0": {
                    "name": "ch1",
                    "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                    "on_demand": true,
                    "debug": false,
                    "status": 0
                },
                "1": {
                    "name": "ch2",
                    "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                    "on_demand": true,
                    "debug": false,
                    "status": 0
                }
            }
        }
    }
}

Stream Control

Stream Add

Query
POST /stream/{STREAM_ID}/add
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
              "name": "test video",
              "channels": {
                  "0": {
                      "name": "ch1",
                      "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                      "on_demand": true,
                      "debug": false,
                      "status": 0
                  },
                  "1": {
                      "name": "ch2",
                      "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                      "on_demand": true,
                      "debug": false,
                      "status": 0
                  }
              }
          }' \
  http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/add
Response
{
    "status": 1,
    "payload": "success"
}

Stream Edit

Query
POST /stream/{STREAM_ID}/edit
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
            "name": "test video",
            "channels": {
                "0": {
                    "name": "ch1",
                    "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                    "on_demand": true,
                    "debug": false,
                    "status": 0
                },
                "1": {
                    "name": "ch2",
                    "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                    "on_demand": true,
                    "debug": false,
                    "status": 0
                }
            }
        }' \
  http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/edit
Response
{
    "status": 1,
    "payload": "success"
}

Stream Reload

Query
GET /stream/{STREAM_ID}/reload
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/reload
Response
{
    "status": 1,
    "payload": "success"
}

Stream Channel Reload

Query
GET /stream/{STREAM_ID}/reload
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/reload
Response
{
    "status": 1,
    "payload": "success"
}

Stream Info

Query
GET /stream/{STREAM_ID}/info
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/info
Response
{
    "status": 1,
    "payload": {
        "name": "test video",
        "channels": {
            "0": {
                "name": "ch1",
                "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                "on_demand": true,
                "debug": false,
                "status": 0
            },
            "1": {
                "name": "ch2",
                "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                "on_demand": true,
                "debug": false,
                "status": 0
            }
        }
    }
}

Stream Delete

Query
GET /stream/{STREAM_ID}/delete
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/delete
Response
{
    "status": 1,
    "payload": "success"
}

Channel Control

Channel Add

Query
POST /stream/{STREAM_ID}/channel/{CHANNEL_ID}/add
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
                      "name": "ch4",
                      "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                      "on_demand": false,
                      "debug": false,
                      "status": 0
            }' \
  http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/add
Response
{
    "status": 1,
    "payload": "success"
}

Channel Edit

Query
POST /stream/{STREAM_ID}/channel/{CHANNEL_ID}/edit
curl --header "Content-Type: application/json" \
  --request POST \
  --data '{
                      "name": "ch4",
                      "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
                      "on_demand": true,
                      "debug": false,
                      "status": 0
            }' \
  http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/edit
Response
{
    "status": 1,
    "payload": "success"
}

Channel Reload

Query
GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/reload
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/reload
Response
{
    "status": 1,
    "payload": "success"
}

Channel Info

Query
GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/info
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/info
Response
{
    "status": 1,
    "payload": {
        "name": "ch4",
        "url": "rtsp://admin:admin@YOU_CAMERA_IP/uri",
        "on_demand": false,
        "debug": false,
        "status": 1
    }
}

Stream Codec

Query
GET /stream/{STREAM_ID}/{CHANNEL_ID}/codec
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/{CHANNEL_ID}/codec
Response
{
    "status": 1,
    "payload": [
        {
            "Record": "AU0AFP/hABRnTQAUlahQfoQAAAMABAAAAwCiEAEABGjuPIA=",
            "RecordInfo": {
                "AVCProfileIndication": 77,
                "ProfileCompatibility": 0,
                "AVCLevelIndication": 20,
                "LengthSizeMinusOne": 3,
                "SPS": [
                    "Z00AFJWoUH6EAAADAAQAAAMAohA="
                ],
                "PPS": [
                    "aO48gA=="
                ]
            },
            "SPSInfo": {
                "ProfileIdc": 77,
                "LevelIdc": 20,
                "MbWidth": 20,
                "MbHeight": 15,
                "CropLeft": 0,
                "CropRight": 0,
                "CropTop": 0,
                "CropBottom": 0,
                "Width": 320,
                "Height": 240
            }
        }
    ]
}

Channel Delete

Query
GET /stream/{STREAM_ID}/channel/{CHANNEL_ID}/delete
curl http://demo:demo@127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/delete
Response
{
    "status": 1,
    "payload": "success"
}

Channel hls play

Query
GET /stream/{STREAM_ID}/hls/live/index.m3u8
curl http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/hls/live/index.m3u8
Response
index.m3u8
ffplay http://127.0.0.1:8083/stream/{STREAM_ID}/channel/{CHANNEL_ID}/hls/live/index.m3u8

Stream rtsp play

Query
ffplay -rtsp_transport tcp  rtsp://127.0.0.1/{STREAM_ID}/{CHANNEL_ID}

Paramerts full multiview page

Grid size
http://localhost:8083/pages/multiview/full?grid=5
Show additional control
http://localhost:8083/pages/multiview/full?controls

Limitations

Video Codecs Supported: H264 all profiles

Audio Codecs Supported: no

Performance

CPU usage ≈0.2%-1% one (thread) core cpu intel core i7 per stream

Authors

  • Andrey Semochkin - Initial work video - deepch
  • Dmitriy Vladykin - Initial work web UI - vdalex25

See also the list of contributors who participated in this project.

License

This project licensed. License - see the LICENSE.md file for details

webrtc follows license MIT license.

joy4 follows license MIT license.

Other Example

Examples of working with video on golang

paypal.me/AndreySemochkin - You can make one-time donations via PayPal. I'll probably buy a coffee tea. 🍵

About

RTSP Stream to WebBrowser

License:Other


Languages

Language:JavaScript 72.6%Language:CSS 17.6%Language:Go 9.8%