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"
}'

The command should return a response that looks something like 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.

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}