Skip to content

ASoc9264/RTSPtoWeb

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

##Installation from binary

Select the latest release

go to https://github.com/deepch/RTSPtoWeb/releases

Download the latest version [$version].tar.gz

wget https://github.com/deepch/RTSPtoWeb/archive/v0.0.1.tar.gz

Extract the archive

tar -xvzf v0.0.1.tar.gz

Change permission

chmod 777 RTSPtoWeb

Run the application

./RTSPtoWeb

##Installation from source

Enable the go module and get the source code

GO111MODULE=on go get github.com/deepch/RTSPtoWeb

Go to working directory

cd src/github.com/deepch/RTSPtoWeb

Run the source

go run *.go

To access the web interface, you open a browser.

http://127.0.0.1:8083

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.

See also included packages.

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 74.6%
  • CSS 17.3%
  • Go 8.1%