...
REST queries and response states
Name
Description
Example
uri
Transcoder URL
transcoder://tcode1
testT
test
REST query | Request example | Response example | Response states | Description | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
/transcoder/startup |
| 400 - Bad request 409 - Conflict 500 - Internal error | Create transcoder with defined parameters for certain stream | |||||||||||||||
/transcoder/find |
|
| 200 – Transcoders found 404 – Transcoders not found | Find the transcoder by certain criteria | ||||||||||||||
/transcoder/find_all |
| 200 – Transcoders found 404 – Transcoders not found | Find all transcoders | |||||||||||||||
/transcoder/terminate |
| 200 - Transcoders is terminated 404 - Transcoder not found | Stop transcoder and its output stream |
Parameters
/transcoder/set_watermark |
| 200 - OK 400 - Bad request 404 - Not found | Add watermark to transcoder output stream |
Parameters
Name | Description | Example |
---|---|---|
uri | Transcoder URL | transcoder://tcode1 |
localStreamName | Transcoder output stream name | testT |
remoteStreamName | Stream name to transcode | test |
localMediaSessionId | Transcoder media session Id | 42a92132-bcd1-4436-a96f-3fec36b32b37 |
status | Transcoder state | PROCESSED_LOCAL |
hasAudio | Output stream has audio | true |
hasVideo | Output stream has video | true |
record | Output stream is recorded | false |
Encoder parameters | ||
width | Picture width | 640 |
height | Picture height | 480 |
keyFrameInterval | Key frame generation interval (GOP) | 30 |
fps | Frames per second | 30 |
bitrate | Bitrate, in kbps | 500 |
type | Codec | OPENH264 |
watermark | Watermark file | Test.png |
...
REST queries and response states
REST query | Request example | Response example | Response states | Description | ||||
---|---|---|---|---|---|---|---|---|
/transcoder2/startup |
|
Name
Description
Example
uri
Transcoder URL
transcoder2://tcode2
testT
test
| 200 - OK 400 - Bad request 409 - Conflict 500 - Internal error | Create transcoder with defined parameters for certain stream | ||||||||||||||||
/transcoder2/find |
|
| 200 – OK 404 – Not found | Find the transcoder by certain criteria | ||||||||||||||
/transcoder/find_all |
| 200 – OK 404 – Not found | Find all transcoders | |||||||||||||||
/transcoder/terminate |
| 200 – OK 404 – Not found | Stop transcoder and its output stream |
Parameters
/transcoder2/set_watermark |
| 200 - OK 400 - Bad request 404 - Not found | Add watermark to transcoder output stream |
Parameters
Name | Description | Example |
---|---|---|
uri | Transcoder URL | transcoder2://tcode2 |
localStreamName | Transcoder output stream name | testT |
remoteStreamName | Stream name to transcode | test |
localMediaSessionId | Transcoder media session Id | 82ad5545-e11e-4f0f-801a-49e69d8c38f2 |
status | Transcoder state | PROCESSED_LOCAL |
hasAudio | Output stream has audio | true |
hasVideo | Output stream has video | true |
record | Output stream is recorded | false |
Encoder parameters | ||
width | Picture width | 320 |
height | Picture height | 240 |
audioCodec | Audio codec | mpeg4-generic |
audioRate | Audio sample rate, Hz | 44100 |
audioChannels | Audio channels | 2 |
audioBitrate | Audio bitrate, bps | 64000 |
videoCodec | Video codec | H264 |
keyFrameInterval | Key frame generation interval (GOP) | 30 |
fps | Frames per second | 30 |
bitrate | Video bitrate, in kbps | 500 |
type | Encoder type | OPENH264 |
watermark | Watermark file | Test.png |
videoRate | Video sample rate, Hz | 90000 |
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
...
Code Block | ||||
---|---|---|---|---|
| ||||
{
"uri": "transcoder://tcode1",
"remoteStreamName": "test",
"localStreamName": "testT",
"encoder": {
"width": 640,
"height": 480,
"keyFrameInterval": 30,
"fps": 30,
"watermark": "/opt/media/Test.png"
}
} |
Multithreaded encoding
...
}
} |
Adding and changing stream watermark dynamically
Since build 5.2.1349 in is possible to dynamically add or change stream watermark without stopping the transcoder. A watermark can be added, changed or moved to another picture location according to coordinates defined using REST API query /transcoder2/set_watermark
Code Block | ||||
---|---|---|---|---|
| ||||
{
"uri":"transcoder2://tcode1",
"watermark":"/opt/media/logo.png",
"x":10,
"y":10,
"marginTop":5,
"marginLeft":5,
"marginBottom":5,
"marginRight":5
} |
Where
- watermark - watermark file name
- x, y - top left watermark corner coordinates on the stream picture
- marginTop, marginLeft, marginBottom, marginRignt - watermark margins from stream picture borders
If watermark coordinates are out of stream picture bounds, the watermark will be scaled to the bounds using margins.
To move watermark to another location on the stream picture, send the query with the same file name and a new coordinates. To remove watermark from the stream picture, send the query with empty watermark
field
Code Block | ||||
---|---|---|---|---|
| ||||
{
"uri":"transcoder2://tcode1",
"watermark":""
} |
Multithreaded encoding
Since build 5.2.816 multithreaded strems encoding is supported using OpenH264 encoder. Encoder threads count can be set with the following parameter
Code Block | ||
---|---|---|
| ||
video_encoder_max_threads=2 |
By default, streams will be encoded in 2 threads.
Multi threaded encoding is enabled depending on transcoder output stream resolution. The threshold can be set with the following parameter
Code Block | ||
---|---|---|
| ||
video_encoder_second_thread_threshold=777000 |
The threshold value is the product of the picture width multiplication to the height. Therefore, 720p and higher resolutions wiil be encoded in multiple threads. This threshold can be lowered if necessary. For example, to encode 480p pictures in multiple threads, set the following value
Code Block | ||
---|---|---|
| ||
video_encoder_second_maxthread_threads=2 |
By default, streams will be encoded in 2 threads.
...
threshold=408950 |
Known issues
1. Encoding quality settings cannot be applied if OpenH264 is used
СSymptoms: picture quality is not changing when using different constraints.video.quality
values, for example
Code Block | ||
---|---|---|
| ||
video_encoder_second_thread_threshold=777000 |
...
constraints.video.quality=5 |
does not differ from
Code Block | ||
---|---|---|
| ||
constraints.video.quality=20 |
Solution: do not use OpenH264 encoder because it does not support CRF
Code Block | ||
---|---|---|
| ||
video_encoder_second_thread_threshold=408950priority=FF |