Create and manage stream files by using the Wowza Streaming Engine REST API

You can use the Wowza Streaming Engine™ media server software REST API to identify, add, and manage stream files in a Wowza Streaming Engine instance.

A stream file is an alias for a complex, URI-based stream name from a source such as an MPEG-TS encoder or IP camera. For example, a stream from an MPEG-TS encoder might have a name like udp://0.0.0.0:10000. You can replace that with a stream file such as mycoolevent.stream. Players can then use mycoolevent.stream in playback URLs in place of the URI-based stream name. Stream files are stored in the /Library/WowzaStreamingEngine/content directory and have a .stream file extension.

Notes:

Get a list of stream files


View a list of stream files associated with an application:

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}/streamfiles

View a list of stream files associated with an application named testlive:

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/testlive/streamfiles

The command should return a response similar to the below:

{
   "serverName": "serverName",
   "streamFiles": [
      {
      "id": "metallica",
      "href": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/streamfiles/streamfile1"
      },
      {
      "id": "saosin",
      "href": "http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/testlive/streamfiles/streamfile2"
      }
   ]
}

View the details of a stream file:

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}/streamfiles/{streamfileName}

The command should return a response that shows the stream file's name and the source URI, like this:

{
   "version": "1430317484000",
   "serverName": "serverName",
   "uri": "udp://0.0.0.0:10000",
   "name": "streamfileName"
}

Add a stream file


Add a stream file named creedance:

curl -X POST \
-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}/streamfiles \
-d'
{
   "name": "creedence",
   "serverName": "serverName",
   "uri": "udp://1.2.3.4:10000"
}'

Depending on the stream type, change the protocol for the value in the uri string. The command returns a response similar to this:

{
  "success": true,
  "message": "",
  "data": null
}

Update a stream file


When using the REST API, you can customize the advanced properties of a stream file. The following example changes the URI to an Axis IP camera and reduces the stream timeout and reconnect wait time for the stream file named creedance:

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}/streamfiles/creedence/adv \
-d '{
        "sourceControlDriver": "",
        "advancedSettings": [{
                "sectionName": "Common",
                "canRemove": false,
                "defaultValue": "null",
                "documented": false,
                "name": "uri",
                "section": "null",
                "type": "string",
                "value": "rtsp://user:pass@[ip-camera]:554/axis-media/media.amp?videocodec=h264&streamprofile=400",
                "enabled": true
        }, {
                "sectionName": "Common",
                "canRemove": true,
                "defaultValue": "12000",
                "documented": true,
                "name": "streamTimeout",
                "section": "null",
                "type": "integer",
                "value": "0",
                "enabled": true
        }, {
                "sectionName": "Common",
                "canRemove": false,
                "defaultValue": "3000",
                "documented": true,
                "name": "reconnectWaitTime",
                "section": "null",
                "type": "integer",
                "value": "0",
                "enabled": true
        }],
        "serverName": "serverName",
        "version": ""
}'

The command should return a response that looks something like this:

{
   "success": true,
   "message:" "",
   "data": null
}

You can also create stream files using MPEG-TS audio and video packet identifiers (PIDs), as in the following example. For the value properties in the MpegtsAudioPID and MpegtsVideoPID blocks, use the values from your encoder.

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}/streamfiles/creedence/adv \
-d '{
        "sourceControlDriver": "",
        "advancedSettings": [{
                "sectionName": "Common",
                "canRemove": false,
                "defaultValue": "null",
                "documented": false,
                "name": "uri",
                "section": "null",
                "type": "string",
                "value": "udp://1.2.3.4:10000",
                "enabled": true
        }, {
                "sectionName": "Common",
                "canRemove": true,
                "defaultValue": "",
                "documented": true,
                "name": "MpegtsAudioPID",
                "section": "null",
                "type": "integer",
                "value": "15",
                "enabled": true
        }, {
                "sectionName": "Common",
                "canRemove": false,
                "defaultValue": "",
                "documented": true,
                "name": "MpegtsVideoPID",
                "section": "null",
                "type": "integer",
                "value": "16",
                "enabled": true
        }],
        "serverName": "serverName",
        "version": ""
}'

Notes:

If you're using multiple audio tracks, you can create separate stream files for each alternative language you would like to ingest. For example, myStream_English.streammyStream_German.stream, etc. To specify the language you would like to play, include a different value for the mpegtsAudioPID property in each of these stream files.

Once done, you can use a SMIL file to choose the correct stream based on the language track. For more, see Use alternative audio or video tracks with Apple HLS streams and Use alternative audio or video tracks with MPEG-DASH streams.

SRT example

With Wowza Streaming Engine 4.8.27, we made changes to improve the creation of SRT stream files via the Wowza Streaming Engine REST API. The mpegTsFilters property was added to the Swagger model for the PUT endpoint that handles updates for advanced stream settings.

If you're creating an SRT stream, first create the stream using the POST request in the Add a stream file section. Omit the mpegTsFilters property in the POST request. Then, update the stream properties with a PUT request to this advanced properties endpoint:

/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/streamfiles/{streamfileName}/adv

While the mpegTSFilter property is optional, it must be included in the body of the PUT request to update the SRT stream and MPEG-TS filters when applicable. For example:

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}/streamfiles/{streamFileName}/adv \
-d '{
        "sourceControlDriver": "",
        "advancedSettings": [{
                "sectionName": "Secure Reliable Transport",
                "canRemove": false,
                "defaultValue": "",
                "documented": false,
                "name": "srtKeyLength",
                "section": "",
                "type": "integer",
                "value": "16",
                "enabled": true
        }, {
                "sectionName": "Secure Reliable Transport",
                "canRemove": false,
                "defaultValue": "",
                "documented": false,
                "name": "srtLatency",
                "section": "",
                "type": "integer",
                "value": "400",
                "enabled": true
        }, {
                "sectionName": "Secure Reliable Transport",
                "canRemove": false,
                "defaultValue": "",
                "documented": false,
                "name": "srtTooLatePacketDrop",
                "section": "",
                "type": "boolean",
                "value": "true",
                "enabled": true
        }],
        "serverName": "serverName",
        "version": "",
        "mpegTSFilters": [{
                "name": "main",
                "mpegtsProgramID": "1",
                "mpegtsVideoPID": "283",
                "mpegtsAudioPID": "0x101"
        }, {
                "name": "main1",
                "mpegtsProgramID": "1",
                "mpegtsVideoPID": "283",
                "mpegtsAudioPID": "0x102"
        }]
}'

Connect a stream file


Initiate the connection of a stream file named creedance:

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}/streamfiles/creedence/actions/connect?connectAppName={appName}&appInstance={instanceName}&mediaCasterType=rtp"

Disconnect a stream file


Disconnect a stream file:

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}/instances/{instanceName}/incomingstreams/{streamfileName}/actions/disconnectStream

Note: Stream files must be disconnected before they can be deleted.

Remove a stream file


Delete a stream file:

curl -X DELETE \
-H 'Accept:application/json; charset=utf-8' \
http://localhost:8087/v2/servers/{serverName}/vhosts/{vhostName}/applications/{appName}/streamfiles/{streamfileName}