Send a stream from Wowza Streaming Engine to Wowza Video Legacy for transcoding using Wowza APIs
With Wowza Streaming Engine™ media server software version 4.2 and later and the Wowza Video™ service, you can send single bitrate streams from Wowza Streaming Engine to Wowza Video Legacy for adaptive bitrate transcoding and delivery to viewers over the Wowza CDN edge network. This workflow allows you to use Wowza Video's high-performance servers and high-bandwidth networks for the heavy lifting of transcoding before delivering the stream to viewers.
In this article, you can learn how to use the Wowza Video REST API and the Wowza Streaming Engine REST API to set up a live application in Wowza Streaming Engine to send a stream to Wowza Video Legacy for transcoding.
info
- The instructions in this article are meant for use with Wowza Streaming Engine versions 4.8.26 and earlier. With Wowza Streaming Engine 4.8.27, we're deprecating the workflow for stream targets that utilize connection codes. For the updated article that replaces the connection code workflow and leverages Wowza's APIs in Wowza Streaming Engine 4.8.27, see Send a stream from Wowza Streaming Engine for transcoding in Wowza Video using Wowza APIs .
- Wowza Streaming Engine 4.7.4 has a known error that may break the stream target functionality for sending streams to Wowza Video Legacy for transcoding. We recommend updating to Wowza Streaming Engine 4.7.5 or later. For more information, see Wowza Streaming Engine 4.7.4 may experience problems sending streams to Wowza Video Legacy for transcoding .
- For a UI-based version of this workflow, see Send a stream from Wowza Streaming Engine for transcoding in Wowza Video .
Before you start
You should be familiar with the following concepts:
- API authentication methods . We use JSON web tokens for API authentication. See Authentication for more information.
- Environment variables . We use environment variables for the API version and your JWT in the cURL API request examples in this topic to make it easier for you to copy, paste, and run commands in your Terminal or Command Prompt window. If you don't set environment variables for these values, you'll need to manually enter the correct values in the code samples throughout this tutorial. See Tools for testing the API for instructions.
1. Create a live stream in Wowza Video Legacy
Create a live stream using the Wowza Video REST API that will receive the stream from Wowza Streaming Engine, transcode it, and deliver it to viewers using the Wowza CDN. You can use the following sample request, making sure to:
-
Set
encoder
towowza_streaming_engine
.
Sample request
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${WV_JWT}" \
-d '{
"live_stream": {
"aspect_ratio_height": 720,
"aspect_ratio_width": 1280,
"billing_mode": "pay_as_you_go",
"broadcast_location": "us_west_california",
"encoder": "wowza_streaming_engine",
"transcoder_type": "transcoded",
"name": "Mylivestream"
}
}' "${WV_HOST}/api/${WV_VERSION}/live_streams"
Sample response
The response includes a connection code to configure Wowza Streaming Engine to send the stream to Wowza Video Legacy.
{
"live_stream": {
"id": "abcrl8v5",
"name": "Mylivestream",
"transcoder_type": "transcoded",
"billing_mode": "pay_as_you_go",
"broadcast_location": "us_west_california",
…
"encoder": "wowza_streaming_engine",
"delivery_method": "push",
"delivery_type": "single-bitrate",
"target_delivery_protocol": "hls-https",
"use_stream_source": false,
"aspect_ratio_width": 1280,
"aspect_ratio_height": 720,
"connection_code": "0oUm9G",
"connection_code_expires_at": "2018-09-01T17:47:58.000Z",
"delivery_protocols": [
"rtmp",
"rtsp",
"wowz"
],
"player": {
"id": "sfjy5pvk",
"type": "original_html5",
"responsive": false,
"width": 640,
"countdown": false,
"embed_code": "in_progress",
"hls_playback_url": "https://[wowzasubdomain]/1/[ID]/hls/live/playlist.m3u8"
}
"hosted_page": {
"enabled": true,
"title": "Mylivestream",
"url": "in_progress",
"sharing_icons": true
}
"stream_targets": [
{
"id": "p63jrlqj"
}
],
"direct_playback_urls": {...},
"created_at": "2018-08-31T17:47:58.000Z",
"updated_at": "2018-08-31T17:47:59.000Z"
}
}
2. Configure a live application in Wowza Streaming Engine
Next, use the Wowza Streaming Engine REST API to configure a live application to ingest a source stream (publisher). You can use the following sample request, making sure to:
-
Set
publisherNamer
to a descriptive name for the publisher.
Sample request
curl -X POST
-H "Accept:application/json" \
-H "charset=utf-8" \
-H "Content-Type:application/json" \
-d '{
"publisherName": "myRTMPencoder"
}' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/publishers/myRTMPencoder"
Sample response
{
"success": true,
"message": "",
"data": null
}
3. Enable push publishing in the Wowza Streaming Engine REST API
Before you can create or use stream targets with the Wowza Streaming Engine REST API, you must enable the push publishing module. To do so, you need to add an advanced property to the application's configuration and add the push publish module to the application.
Start by retrieving the details of the application's advanced settings and a list of the modules the application is using. Retrieve the
information by sending a GET
call to the endpoint /v2/servers/[serverName]/vhosts/[vhostName]/applications/[appName]/adv
.
info
Wowza Streaming Engine REST API requests must include three headers: Accept:application/json, Content-Type:application/json, and charset=utf-8. For more information, see Query the Wowza Streaming Engine REST API.
Example request:
curl -X GET \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv"
The request returns an object (advancedSettings
) that shows the application's advanced settings and a modules
list of the modules in
use. The response looks something like this:
{
"version": "1543353224014",
"serverName": "serverName",
"advancedSettings": [
{
"enabled": false,
"canRemove": true,
"name": "debugAACTimecodes",
"value": "false",
"defaultValue": "false",
"type": "Boolean",
"sectionName": "cupertinostreamingpacketizer",
"section": "/Root/Application/LiveStreamPacketizer",
"documented": true
},
{
"enabled": false,
"canRemove": true,
"name": "debugMP3Timecodes",
"value": "false",
"defaultValue": "false",
"type": "Boolean",
"sectionName": "cupertinostreamingpacketizer",
"section": "/Root/Application/LiveStreamPacketizer",
"documented": true
},
...
],
"modules": [
{
"order": 0,
"name": "base",
"description": "Base",
"class": "com.wowza.wms.module.ModuleCore"
},
{
"order": 1,
"name": "logging",
"description": "Client Logging",
"class": "com.wowza.wms.module.ModuleClientLogging"
},
{
"order": 2,
"name": "flvplayback",
"description": "FLVPlayback",
"class": "com.wowza.wms.module.ModuleFLVPlayback"
},
{
"order": 3,
"name": "ModuleCoreSecurity",
"description": "Core Security Module for Applications",
"class": "com.wowza.wms.security.ModuleCoreSecurity"
},
]
}
Now, execute a PUT
command to accomplish two tasks:
-
Add the
pushPublishMapPath
property to the application's configuration and -
Append the
ModulePushPublish
to the complete list of modules in use.
info
The PUT command must include all of the existing modules in use by the application as well as the push publish module; use the response from the GET call to enumerate the modules that precede ModulePushPublish in the PUT call.
The command calls the same endpoint, /v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv
, and looks like this:
curl -X PUT \
-H 'Accept:application/json; charset=utf-8' \
-H 'Content-Type:application/json; charset=utf-8' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/adv"
{
"version": "1543353224014",
"serverName": "serverName",
"advancedSettings": [
{
"enabled": true,
"canRemove": false,
"name": "pushPublishMapPath",
"value": "${com.wowza.wms.context.VHostConfigHome}/conf/${com.wowza.wms.context.Application}/PushPublishMap.txt",
"defaultValue": null,
"type": "String",
"sectionName": "Application",
"section": "/Root/Application",
"documented": false
}
],
"modules": [
{
"order": 0,
"name": "base",
"description": "Base",
"class": "com.wowza.wms.module.ModuleCore"
},
{
"order": 1,
"name": "logging",
"description": "Client Logging",
"class": "com.wowza.wms.module.ModuleClientLogging"
},
{
"order": 2,
"name": "flvplayback",
"description": "FLVPlayback",
"class": "com.wowza.wms.module.ModuleFLVPlayback"
},
{
"order": 3,
"name": "ModuleCoreSecurity",
"description": "Core Security Module for Applications",
"class": "com.wowza.wms.security.ModuleCoreSecurity"
},
{
"order": 4,
"name": "ModulePushPublish",
"description": "ModulePushPublish",
"class": "com.wowza.wms.pushpublish.module.ModulePushPublish"
}
]
}
Finally, restart the application, and then you can create and edit stream targets using the Wowza Streaming Engine REST API.
curl -X PUT \
-H 'Accept:application/json; charset=utf-8' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/actions/restart"
4. Create a stream target in Wowza Streaming Engine
Still in the Wowza Streaming Engine REST API, create a stream target for your application. You can use the following sample request, making sure to:
-
Set
connectionCode
to theconnection_code
from the Wowza Video Legacy live stream -
Set
enabled
totrue
-
Set
profile
towowza-streaming-video
-
Set
sourceStreamName
to the name of the incoming stream for the application -
Set
wowzaVideoDestinationType
totranscoder
-
Set
wowzaVideo.adaptiveStreaming
tofalse
-
Set the
appName
to match your application
Sample request
curl -X POST \
-H "Accept:application/json" \
-H "charset=utf-8" \
-H "Content-Type:application/json" \
-d '{
"connectionCode": "0oUm9G ",
"enabled": true,
"entryName": "videoLiveStream",
"profile": "wowza-streaming-video",
"sourceStreamName": "myStream",
"wowzaVideo.adaptiveStreaming": "false",
"extraOptions": {
"wowzaVideoDestinationType": "transcoder",
"destinationName": "wowzastreamingvideo"
}
}' \
"http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/pushpublish/mapentries/{entryName}"
Sample response
{
"success": true,
"message": "Entry (videoLiveStream) saved successfully",
"data": null
}
5. Test the connection
With your application configured to ingest source stream and deliver it to Wowza Video Legacy, you're ready to test your workflow.
- Configure your source encoder or camera. See Connect a live source to Wowza Streaming Engine for more information.
-
Start your live stream.
curl -X PUT \ -H "Authorization: Bearer ${WV_JWT}" \ "${WV_HOST}/api/${WV_VERSION}/live_streams/{live_stream_ID}/start"
-
Check the state to make sure the live stream started.
curl -X GET \ -H "Authorization: Bearer ${WV_JWT}" \ "${WV_HOST}/api/${WV_VERSION}/live_streams/{live_stream_ID}/state"
- Start the stream in the H.264 camera or encoder that's sending the stream to your application in Wowza Streaming Engine.
-
Fetch a URL to a thumbnail that you can enter into a browser and visually confirm the stream is playing.
curl -X GET \ -H "Authorization: Bearer ${WV_JWT}" \ "${WV_HOST}/api/${WV_VERSION}/livestreams/{live_stream_ID}/thumbnail_url"
-
Stop the live stream.
curl -X PUT \ -H "Authorization: Bearer ${WV_JWT}" \ "${WSV_HOST}/api/${WV_VERSION}/live_streams/{live_stream_ID}/stop"
- Stop the stream in the source camera or encoder.
Related API requests
-
GET /live_streams/[id]
— View the details of a live stream. -
DELETE /live_streams/[live_stream_id]
— Delete a live stream. -
GET /live_streams/[live_stream_id]/regenerate_connection_code
— Regenerate a target's connection code.