The Wowza Streaming Cloud™ service allows you to deliver live streams to viewers over multiple protocols: RTMP, RTSP, WOWZ, and WebRTC directly from the transcoder, and HLS from a CDN endpoint. If latency is a concern, direct RTMP, RTSP, WOWZ, or WebRTC playback is the faster option, but the number of concurrent viewers who can watch your stream this way is limited. HLS delivery from a CDN endpoint, on the other hand, allows you to reach more viewers—and more geographically dispersed viewers—but the latency is greater.
This article explains how to use the Wowza Streaming Cloud REST API to deliver streams with reduced latency and a more scalable deployment. The delivery methods used in this article provide an example. You can choose to just use one, or customize the destinations and settings in whatever way makes sense for your streaming needs.
Note: For information about ultra low latency streaming, see the Get started with ultra low latency streaming using the Wowza Streaming Cloud REST API.
About latency over direct playback URLs and HLS
A lower-latency workflow can be used to deliver a stream directly from the Wowza Streaming Cloud transcoder (the origin server) to your audience over RTMP, RTSP, WOWZ, or WebRTC direct playback URLs. Under optimal conditions—the viewer is close to your broadcast location, network conditions are good, and your source encoding settings are optimal—delivering a stream directly from the Wowza Streaming Cloud transcoder to viewers offers latency as low as 1 second. The advantage of this reduced latency, however, may be offset by the facts that the transcoder has a limit for viewer connections and latency increases the farther the viewer is located from the transcoder.
A second option for lower-latency streaming is to use a Wowza CDN on Fastly stream target or Wowza CDN on Akamai - HLS stream target that parses the stream into small media segments, or short chunks. By reducing the HLS media segment size from the default 10 seconds to 2 seconds, you can achieve a latency of as low as 8 to 10 seconds. Both types of Wowza CDN targets have no restrictions on the number of viewers who can access the stream, and they are widely distributed, with servers that are close to viewers wherever they watch. And because HLS is based on HTTP, it performs well on all kinds of networks.
Note: Although delivering shorter audio and video file segments can reduce latency, shorter file segments also create additional network overhead for the client. If the client doesn't have enough bandwidth, playback may stall, which results in a poor viewing experience.
Create a reduced-latency transcoder and a passthrough output for direct RTMP playback
Start by using the Wowza Streaming Cloud REST API to create a transcoder that receives video from a source encoder and delivers a passthrough stream to your targets. Use the following transcoder parameters for your reduced-latency workflow.
Reduced-latency transcoder parameters
Parameter | Data Type | Description |
broadcast_location | string | Specify the region that's closest to where your stream originates. Valid values are asia_pacific_australia, asia_pacific_india, asia_pacific_japan, asia_pacific_taiwan, eu_belgium, eu_germany, eu_ireland, south_america_brazil, us_central_iowa, us_east_s_carolina, us_east_virginia, us_west_california, and us_west_oregon.Notes: |
buffer_size | integer | Specify 0. |
low_latency | Boolean | Specify true to speed the time it takes to decode and deliver video data to the player by turning off the sort packet buffer. |
play_maximum_connections | integer | The number of connections that can access the transcoder's RTMP playback URL. The default is 10. |
stream_smoother | Boolean | Use the default, false. (Stream smoothing is not available when the buffer is 0.) |
transcoder_type | string |
Specify passthrough.
|
Example request and response
Notes:Create the transcoder:
- To authenticate API requests, use HMAC authentication for production environments. For testing or proof of concept purposes only, use API key and access key authentication.
- The curl examples below use environment variables. See Using cURL for more information on how to set these up.
curl -X POST \ -H 'Content-Type: application/json' \ -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ -d '{ "transcoder": { "billing_mode": "pay_as_you_go", "broadcast_location": "eu_belgium", "buffer_size": 0, "delivery_method": "push", "low_latency": true, "name": "MyLowLatencyTranscoder", "play_maximum_connections": 100, "protocol": "rtmp", "stream_smoother": false, "transcoder_type": "passthrough" } }' "${WSC_HOST}/api/${WSC_VERSION}/transcoders/"
The command creates a passthrough transcoder with an id parameter (1234abcd in this example) but no outputs ("outputs": []). The details of the configured transcoder are listed in the response, which should look something like this:
{ "transcoder": { "application_name": "app-B8P6K226", "billing_mode": "pay_as_you_go", "broadcast_location": "eu_belgium", "buffer_size": 0, "closed_caption_type": none, "created_at": "2016-04-22T13:33:16.575", "delivery_method": "push", "delivery_protocols": [ "rtmp", "rtsp", "wowz", "webrtc" ], "direct_playback_urls": {...}, "disable_authentication": false, "domain_name": "[subdomain].entrypoint.cloud.wowza.com", "id": "1234abcd", "idle_timeout": 1200, "low_latency": true, "name": "MyLowLatencyTranscoder", "outputs": [], "password": "12345678", "playback_stream_name": "f8758cd3", "play_maximum_connections": 100, "protocol": "rtmp", "source_port": 1935, "stream_name": "1a2a3a4a", "stream_smoother": false, "suppress_stream_target_start": false, "transcoder_type": "passthrough", "updated_at": "2016-04-22T13:33:16.575", "username": "client1", "watermark": false } }
Create the passthrough output:
curl -X POST \ -H "Content-Type: application/json" \ -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ -d '{ "output": { "video_codec": "passthrough", "audio_codec": "passthrough" } }' "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/outputs"
The command creates the output with an id parameter (5678efgh in this example) but no targets ("output_stream_targets": []). The details of the configured output are listed in the response, which should look something like this:
{ "output": { "bitrate_audio": 0, "bitrate_video": 0, "created_at": "2016-04-28T11:01:26.044", "framerate_reduction": 0, "h264_profile": null, "id": "5678efgh", "keyframes": "follow_source", "name": "Video+Audio=Passthrough+Passthrough", "video_codec": "passthrough", "audio_codec": "passthrough", "output_stream_targets": [], "transcoder_id": "1234abcd", "updated_at": "2016-04-28T11:01:26.044" } }
Add a stream target
Next, add a Wowza CDN on Fastly stream target that delivers the stream to geographically distributed Wowza CDN endpoints. You can also use a Wowza CDN on Akamai stream target for this step.
Wowza CDN on Fastly stream target parameter
Parameter | Data Type | Description |
name | string | A descriptive name for the stream target such as MyLowLatencyHLStarget. |
Example request and response
Create the target:curl -X POST \ -H 'Content-Type: application/json' \ -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ -d '{ "stream_target_fastly": { "name": "MyLowLatencyHLStarget" } }' "${WSC_HOST}/api/${WSC_VERSION}/stream_targets/fastly"
The command creates the target with an id parameter (3456mnop in this example). The details of the configured target are listed in the response, which should look something like this:
{ "stream_target_fastly": { "id": "3456mnop", "name": "MyLowLatencyHLStarget", "state": "activated" "stream_name": "6f86005b", "playback_urls": { "hls": [ { "name": "default", "url": "https://[subdomain].wowza.com/1/abc2TnJwZEpwXYz/6f86005b/hls/live/playlist.m3u8" } ] }, "token_auth_enabled": false, "token_auth_playlist_only": false, "geoblock_enabled": false, "geoblock_by_location": "disabled", "geoblock_ip_override": "disabled", "force_ssl_playback": false, "created_at": "2020-01-28T11:01:45.044" "updated_at": "2020-01-28T11:01:45.044" } }
Reduce the chunk size of the stream target
Reduce the duration of the stream's HLS segments by specifying a small chunk size property for the target:
curl -X POST \ -H 'Content-Type: application/json' \ -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ -d '{ "property": { "key": "chunkSize", "section": "hls", "value": "2" } }' "${WSC_HOST}/api/${WSC_VERSION}/stream_targets/[stream_target_id]/properties"
The command assigns a chunk size (media segment size) of 2 to the target. The details of the target's property are listed in the response, which should look something like this:
{ "property": { "key": "chunkSize", "section": "hls", "value": "2" } }
Assign the stream target to the output
Assign the Wowza CDN on Fastly stream target to the output:
curl -X POST \ -H 'Content-Type: application/json' \ -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ -d '{ "output_stream_target": { "stream_target_id": "3456mnop", "use_stream_target_backup_url": false } }' "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]/outputs/[output_id]/output_stream_targets"
Get the transcoder's direct playback URLs
Get the transcoder's direct playback URLs so that viewers can play from the transcoder via RTMP, RTSP, WOWZ, or WebRTC:
curl -X GET \ -H "wsc-api-key: ${WSC_API_KEY}" \ -H "wsc-access-key: ${WSC_ACCESS_KEY}" \ "${WSC_HOST}/api/${WSC_VERSION}/transcoders/[transcoder_id]"