How to 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:

Contents


Get a list of stream files
Add a stream file
Update a stream file
Connect a stream file
Disconnect a stream file
Remove a stream file

Get a list of stream files


View a list of stream files associated with an application (live, in this example):

curl -X GET --header "Accept:application/json; charset=utf-8" --header "Content-Type:application/json; charset=utf-8" http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles

The command should return a response that lists the stream files (metallica and saosin in this example) and looks something like this:

{
   "serverName": "_defaultServer_",
   "streamFiles": [
      {
      "id": "metallica",
      "href": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/metallica"
      },
      {
      "id": "saosin",
      "href": "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/saosin"
      }
   ]
}

View the details of a stream file (metallica, in this example):

curl -X GET --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/metallica

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

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

Add a stream file


Add a stream file (creedence, in this example):

curl -X POST --header 'Accept:application/json; charset=utf-8' --header 'Content-Type:application/json; charset=utf-8'  http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles -d'
{
   "name": "creedence",
   "serverName": "_defaultServer_",
   "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


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 creedence:

curl -X PUT --header 'Accept: application/json; charset=utf-8' --header 'Content-Type: application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/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": false
    }, {
        "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": "_defaultServer_",
    "saveFieldList": [
        ""
    ],
    "version": ""
}
'

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

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

Connect a stream file


Initiate the connection of a stream file (creedence, in this example):

curl -X PUT --header 'Accept:application/json; charset=utf-8' --header 'Content-type:application/json; charset=utf-8' "http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/streamfiles/creedence/actions/connect?connectAppName=live&appInstance=_definst_&mediaCasterType=rtp"

Disconnect a stream file


Disconnect a stream file (creedence, in this example):

curl -X PUT --header 'Accept:application/json; charset=utf-8' --header 'Content-Type:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/instances/_definst_/incomingstreams/creedence.stream/actions/disconnectStream

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

Remove a stream file


Delete a stream file (creedence, in this example):

curl -X DELETE --header 'Accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultServer_/vhosts/_defaultVHost_/applications/live/streamfiles/creedence

If you're having problems or want to discuss this article, post in our forum.