Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Transcoding management with REST API

Obsolete REST API version (server builds before 5.2.898)

REST query should be HTTP/HTTPS POST request as:

...

  • test.flashphoner.com is WCS server address
  • 8081 is a standard REST / HTTP port of  WCS server
  • 8444 is a standard HTTPS port
  • rest-api is mandatory URL prefix
  • /transcoder/startup is REST query

REST queries and response states

REST query

Request example

Response example

Response states

Description

/transcoder/startup

Code Block
languagejs
themeRDark
{
 "uri": "transcoder://tcode1",
 "remoteStreamName": "test",
 "localStreamName": "testT",
 "encoder": {
  "width": 640,
  "height": 480,
  "keyFrameInterval": 30,
  "fps": 30,
  "watermark": "Test.png"
 }
}

400 - Bad request

409 - Conflict

500 - Internal error


Create transcoder with defined parameters for certain stream


/transcoder/find
Code Block
languagejs
themeRDark
{
 "remoteStreamName": "test"
}
Code Block
languagejs
themeRDark
[
    {
        "localMediaSessionId": "42a92132-bcd1-4436-a96f-3fec36b32b37",
        "localStreamName": "testT",
        "remoteStreamName": "test",
        "uri": "transcoder://tcode1",
        "status": "PROCESSED_LOCAL",
        "hasAudio": true,
        "hasVideo": true,
        "record": false,
        "encoder": {
            "width": 640,
            "height": 480,
            "keyFrameInterval": 30,
            "fps": 30,
            "watermark": "Test.png"
        }
    }
]

200 – Transcoders found

404 – Transcoders not found

Find the transcoder by certain criteria

/transcoder/find_all


Code Block
languagejs
themeRDark
[
    {
        "localMediaSessionId": "42a92132-bcd1-4436-a96f-3fec36b32b37",
        "localStreamName": "testT",
        "remoteStreamName": "test",
        "uri": "transcoder://tcode1",
        "status": "PROCESSED_LOCAL",
        "hasAudio": true,
        "hasVideo": true,
        "record": false,
        "encoder": {
            "width": 640,
            "height": 480,
            "keyFrameInterval": 30,
            "fps": 30
        }
    }
]

200 – Transcoders found

404 – Transcoders not found


Find all transcoders

/transcoder/terminate

Code Block
languagejs
themeRDark
{
"uri":"transcoder://tcode1"
}

200 - Transcoders is terminated

404 - Transcoder not found

Stop transcoder and its output stream

...

Name

Description

Example

uri

Transcoder URL

transcoder://tcode1
localStreamNameTranscoder output stream name
testT
remoteStreamNameStream name to transcode
test
localMediaSessionIdTranscoder media session Id
42a92132-bcd1-4436-a96f-3fec36b32b37

status

Transcoder state

PROCESSED_LOCAL
hasAudioOutput stream has audio
true
hasVideoOutput stream has video
true
recordOutput stream is recorded
false
Encoder parameters
widthPicture width
640
heightPicture height
480
keyFrameIntervalKey frame generation interval (GOP)
30
fpsFrames per second
30
bitrateBitrate, in kbps
500
typeCodec
OPENH264
watermarkWatermark fileTest.png

Known limits

1. Transcoder cannot be created by REST API for audio only stream. In response to /transcoder/startup query for such stream, server returns 400 Bad request with message "Can't start transcoder for audio only stream"

...

4, If only width is specified, the quey return 400 Bad request with message "Height is not specified"

REST API version 2 (server builds since 5.2.898)

REST query should be HTTP/HTTPS POST request as:

  • HTTP: http://test.flashphoner.com:8081/rest-api/transcoder2/startup
  • HTTPS: https://test.flashphoner.com:8444/rest-api/transcoder2/startup

Where:

  • test.flashphoner.com is WCS server address
  • 8081 is a standard REST / HTTP port of  WCS server
  • 8444 is a standard HTTPS port
  • rest-api is mandatory URL prefix
  • /transcoder2/startup is REST query

REST queries and response states

REST query

Request example

Response example

Response states

Description

/transcoder2/startup

Code Block
languagejs
themeRDark
{
 "uri": "transcoder2://tcode2",
 "remoteStreamName": "test",
 "localStreamName": "testT",
 "encoder": {
  "videoCodec": "H264",
  "audioCodec": "mpeg4-generic",
  "width": 320,
  "height": 240,
  "keyFrameInterval": 60,
  "fps": 30,
  "audioRate": 44100
 }
}

200 - OK

400 - Bad request

409 - Conflict

500 - Internal error


Create transcoder with defined parameters for certain stream


/transcoder2/find
Code Block
languagejs
themeRDark
{
 "remoteStreamName": "test"
}
Code Block
languagejs
themeRDark
[
  {
    "localMediaSessionId": "82ad5545-e11e-4f0f-801a-49e69d8c38f2",
    "localStreamName": "testT",
    "remoteStreamName": "test",
    "uri": "transcoder2://tcode2",
    "status": "PROCESSED_LOCAL",
    "hasAudio": true,
    "hasVideo": true,
    "record": false,
    "encoder": {
      "width": 320,
      "height": 240,
      "keyFrameInterval": 60,
      "fps": 30,
      "audioRate": 44100,
      "audioCodec": "mpeg4-generic",
      "videoCodec": "H264",
      "videoRate": 90000
    }
  }
]

200 – OK

404 – Not found

Find the transcoder by certain criteria

/transcoder/find_all


Code Block
languagejs
themeRDark
[
  {
    "localMediaSessionId": "82ad5545-e11e-4f0f-801a-49e69d8c38f2",
    "localStreamName": "testT",
    "remoteStreamName": "test",
    "uri": "transcoder2://tcode2",
    "status": "PROCESSED_LOCAL",
    "hasAudio": true,
    "hasVideo": true,
    "record": false,
    "encoder": {
      "width": 320,
      "height": 240,
      "keyFrameInterval": 60,
      "fps": 30,
      "audioRate": 44100,
      "audioCodec": "mpeg4-generic",
      "videoCodec": "H264",
      "videoRate": 90000
    }
  }
]

200 – OK

404 – Not found

Find all transcoders

/transcoder/terminate

Code Block
languagejs
themeRDark
{
 "uri":"transcoder2://tcode2"
}

200 – OK

404 – Not found

Stop transcoder and its output stream

Parameters

Name

Description

Example

uri

Transcoder URL

transcoder2://tcode2
localStreamNameTranscoder output stream name
testT
remoteStreamNameStream name to transcode
test
localMediaSessionIdTranscoder media session Id
82ad5545-e11e-4f0f-801a-49e69d8c38f2

status

Transcoder state

PROCESSED_LOCAL
hasAudioOutput stream has audio
true
hasVideoOutput stream has video
true
recordOutput stream is recorded
false
Encoder parameters
widthPicture width
320
heightPicture height
240
audioCodecAudio codecmpeg4-generic
audioRateAudio sample rate, Hz 44100
audioChannelsAudio channels2
videoCodecVideo codecH264
keyFrameIntervalKey frame generation interval (GOP)
30
fpsFrames per second
30
bitrateVideo bitrate, in kbps
500
typeEncoder type
OPENH264
watermarkWatermark fileTest.png
videoRateVideo sample rate, Hz90000

Known limits

1. If video transcoding parameters are passed for audio only stream, or audio transcoding parameters are passed for video only stream, 400 Bad request will return

Quick manual for testing

1. For test we use

...