CamStreamer App 3.x API Documentation

CamStreamer App 3.x functionality can be controlled using API once the application is installed and licensed. There are several parameters described below. Mind that CamStreamer application/stream is restarted every time any parameter is changed.

Global Parameters

You can get or set multiple global parameters at once usign the following calls:

http://IPADDR[:PORT]/local/camstreamer/param/set.cgi?PARAMNAME=PARAMVALUE[&PARAMNAME=PARAMVALUE]

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
PARAMNAME is a name of any parameter listed below.
PARAMVALUE is a value you would like to save to CamStreamer. Special characters in the value has to be urlenmarkd. See URL encoding

http://IPADDR[:PORT]/local/camstreamer/param/get.cgi?list=PARAMNAME[,PARAMNAME]

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
PARAMNAME is a name of any parameter listed below.

In Camstreamer it is possible to set up several output streams directly by setting JSON array to StreamList parameter or by using simpler HTTP API. Every stream has its own parameters (listed below) which can be set or gained by calling HTTP API.


List of global parameters:


Parameter LiveLED

Enable LED light indication on the camera. The light is ON if the stream is established. The light is off once the CamStreamer is not able to broadcast the video. Valid values: 0, 1


Stream Parameters

The following HTTP API call list all streams.

http://IPADDR[:PORT]/local/camstreamer/stream/list.cgi

You can add / update a stream by the set.cgi HTTP API call bellow. Mind that the stream added by API is not visible in the CamStreamer user interface. If you'd like to start a broadcast on YouTube, please use YouTube Live Streaming API. It's necessary to obtain an RTMP ingestion url / key.

http://IPADDR[:PORT]/local/camstreamer/stream/set.cgi?stream_id=STREAMID&PARAMNAME=PARAMVALUE[&PARAMNAME=PARAMVALUE]

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier (string). A new stream is created if stream_id is empty. For API are reserved identifiers with "api" prefix.
PARAMNAME is a name of any stream parameter listed below.
PARAMVALUE is a value you would like to save to the stream. Special characters in the value has to be urlenmarkd. See URL encoding

You can get a stream parameters by the get.cgi HTTP API call bellow.

http://IPADDR[:PORT]/local/camstreamer/stream/get.cgi?stream_id=STREAMID

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier.



You can remove a stream by the remove.cgi HTTP API call bellow.

http://IPADDR[:PORT]/local/camstreamer/stream/remove.cgi?stream_id=STREAMID

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier.


List of stream parameters:


Parameter enabled

Stop or start the stream using parameter "Enabled". Valid values: 0, 1

Parameter mediaServerUrl

Valid values (for selected protocol):

RTMP
rtmp://[user:pass@]server:port[/app][/stream_name]
MPEG-TS TCP
tcp://server:port
MPEG-TS UDP
udp://server:port[?pkt_size=XXX&ttl=XXX]
HLS PULL
http://IPADDR:PORT/local/camstreamer/live.m3u8
where: IPADDR:PORT is an IP address:port of the camera.
HLS PUSH
ftp://your_ftp_server/live.m3u8
SRT
Mode Caller (push): srt://:port
Mode Listener (pull): srt://server:port
You can stop or start the stream using parameter "Enabled". Valid values: 0, 1

Parameter userVapixParameters

Overwrite the default video parameters. See parameter description (chapter 3.4). You can e.g. choose different camera or View Area using parameter camera=2&resolution=1280x720&overlaypos=200%2C600.

Parameter audioSource

Specify the audio channel. Available values:

none disable the audio channel.
default use the audio channel from the camera (e.g. mic./line input).
file: FILEPATH use an audio file FILEPATH (mka/mp3) on the file system on the camera (e.g. SD card). If you want to stream to YouTube with camera without audio, use following settings "audioSource=file:/usr/local/packages/camstreamer/tools/silence.mka"
url: URL use an external (network) audio source (markc AAC or MP3). E.g. internet radio, another camera or Axis P8221 audio enmarkr. For Axis device: rtsp://root:password@IPaddress/axis-media/media.amp?audio=1&video=0 Use audio sample rate 44.1KHz and bitrate 128Kbps. CamStreamer is not streaming once the external audio is not available.

Parameter avSyncMsec

Time offset for audio/video channel in milliseconds.

Parameter active

Pause stream – the stream will not run, but all other processes are active. Typical API server calls in callApi – the application calls server APIs (creation and ending streams on YouTube).

Parameter trigger

Determines type of automation.

none automation off
inputX (X is the input number) the stream is turned on only if the given camera input is active
time stream is turned on based on a time interval (startTime / stopTime parameters)

Parameter prepareAhead

(only trigger time) – prepares a stream for a given number of seconds before startTime (calls API, starts to stream).

Parameter startTime

(only trigger time) - unix timestamp for the beginning of the stream.

Parameter stopTime

(only trigger time) - unix timestamp for the end of the stream.


Get current YouTube Live broadcast

Redirect your viewers to the current broadcast.

https://camstreamer.com/yt-broadcast-api/SECTOKEN/CSID

where SECTOKEN and CSID are used in "Permanent link" in CamStreamer user interface. Mind that the SECTOKEN is changed once you use a different YouTube channel.

Example:

https://camstreamer.com/yt-broadcast-api/b7133489237eee1/S-78

Response:

{"broadcast_id":"XCIfaGvbXSs"}

Status of YouTube Live broadcast

Check whether the YouTube broadcast is live and whether the you Get information from our watchdog. It is suitable for integration with monitoring systems like Nagios, Centreon...

https://camstreamer.com/api/youtubeStatus/SECTOKEN/CSID

where SECTOKEN and CSID are used in "Permanent link" in CamStreamer user interface. Mind that the SECTOKEN is changed once you use a different YouTube channel.

Response HTTP code:

  • 200 Stream ok
  • 404 Stream not found or bad security token
  • 400 Stream not checked yet
  • 400 Stream interrupted


Practical Examples


When you’re creating a new stream, use a different ID than the one created by the CamStreamer App. Our application uses whole numbers higher than 10. Use a prefix like “api_01”. A YouTube stream may be controlled via an API, but YouTube authorization first has to be carried out via a user interface.

In order for the camera to stream, the following conditions must be met: parameter enabled = 1, parameter active = 1 and parameter trigger = none or automation was active (input on or correct time interval)


Creation / modification of a new nonstop RTMP stream


PARAMETERS:
"enabled":"1",
"audioSource":"default",
"mediaServerUrl":"rtmp:\/\/a.rtmp.youtube.com\/live2\/rfp-test-2926.q9yk-3wv0-4zzg-78ks"

You can change a stream parameters by the set.cgi HTTP API call bellow.

http://IPADDR[:PORT]/local/camstreamer/stream/set.cgi?stream_id=STREAMID&enabled=1&audioSource=default&mediaServerUrl=rtmp://a.rtmp.youtube.com/live/rfp-test-2926.q9yk-3wv0-4zzg-78ks

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier (string). A new stream is created if stream_id is empty. For API are reserved identifiers with "api" prefix.


Stopping an RTMP stream


PARAMETERS:
"enabled":"0"

You can stop a stream by the set.cgi HTTP API call bellow.

http://IPADDR[:PORT]/local/camstreamer/stream/set.cgi?stream_id=1057&enabled=0

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier (string). A new stream is created if stream_id is empty. For API are reserved identifiers with "api" prefix.


Creation / modification of a new RTMP stream by pressing button 1


PARAMETERS:
"enabled":"1",
"audioSource":"default",
"trigger":"input0",
"mediaServerUrl":"rtmp:\/\/a.rtmp.youtube.com\/live2\/rfp-test-2926.q9yk-3wv0-4zzg-78ks"

You can create / modificate a stream by the set.cgi HTTP API call bellow.

http://IPADDR[:PORT]/local/camstreamer/stream/set.cgi?stream_id=1057&enabled=1&audioSource=default&trigger=input0&mediaServerUrl=rtmp%3A%2F%2Fa.rtmp.youtube.com%2Flive2%2Frfp-test-2926.q9yk-3wv0-4zzg-78ks

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier (string). A new stream is created if stream_id is empty. For API are reserved identifiers with "api" prefix.


Creation / modification of a new RTMP stream from 2019-03-04 11:10 to 2019-03-04 14:10 in UTC+01


"enabled":"1",
"audioSource":"default",
"trigger":"time",
"startTime":"1551694200",
"stopTime":"1551705000",
"mediaServerUrl":"rtmp:\/\/a.rtmp.youtube.com\/live2\/rfp-test-2926.q9yk-3wv0-4zzg-78ks"

You can create / modificate a stream by the set.cgi HTTP API call bellow.

http://IPADDR[:PORT]/local/camstreamer/stream/set.cgi?stream_id=1057&enabled=1&audioSource=default&trigger=time&startTime=1551694200&stopTime=1551705000&mediaServerUrl=rtmp%3A%2F%2Fa.rtmp.youtube.com%2Flive2%2Frfp-test-2926.q9yk-3wv0-4zzg-78ks

where

IPADDR[:PORT] is an IP address:port of the camera. E.g. 192.168.1.5
STREAMID is a stream identifier (string). A new stream is created if stream_id is empty. For API are reserved identifiers with "api" prefix.




Feel free to contact our support in case of any problem.