Skip to content

API Examples

Will edited this page Apr 6, 2023 · 6 revisions

Example for creating a new transcoding service through the API:

curl --verbose -d "@newsource_transcode.json" -H "Content-Type: application/json" -X POST http://localhost:8080/api/v1/newsource

This will return a "servicenum" field for the new service that you've created:

{"servicenum":1566265416}

where newsource_transcode.json is as follows:

{
    "filletmode": "transcode",
    "sourcename": "Sports Network",
    "ipaddr_primary": "0.0.0.0:2500",
    "inputinterface1": "enp0s25",
    "ipaddr_backup": "",
    "inputinterface2": "",
    "enablehls": "on",
    "enabledash": "on",
    "windowsize": "10",
    "segmentsize": "2",
    "enablescte35": "off",
    "videocodec": "h264",
    "videoquality": "0",
    "audiosources": "1",
    "enablestereo": "on",
    "audiobitrate": "96",
    "outputenabled1": "on",
    "outputresolution1": "320x240",
    "video_bitrate1": "1250",
    "outputenabled2": "on",
    "outputenabled3": "on",
    "outputenabled4": "on",
    "manifestdirectory": "/var/www/html/sportstv",
    "hlsmanifest": "master.m3u8",
    "fmp4manifest": "masterfmp4.m3u8",
    "dashmanifest": "master.mpd",
    "managementserverip": "",
    "publishpoint1": "",
    "cdnusername1": "",
    "cdnpassword1": ""
}

Example for listing the transcoding/packaging services via the API:

Locate the service returned by list_services:

curl http://127.0.0.1:8080/api/v1/list_services
{
 "service_list":
    [{"serviceindex":1,"servicenum":"1557282059"},
     {"serviceindex":2,"servicenum":"1557453688"},
     {"serviceindex":3,"servicenum":"1558496789"},
     {"serviceindex":4,"servicenum":"1566265416"}
    ]
}

Starting a Service

curl --verbose -X POST http://127.0.0.1:8080/api/v1/start_service/1566265416

Stopping a Service

curl --verbose -X POST http://127.0.0.1:8080/api/v1/stop_service/1566265416

Getting the Service Status

curl http://127.0.0.1:8080/api/v1/get_service_status/1566265416
{
    "uptime":230,
    "input_signal":1,
    "input_interface":"enp0s25",
    "source_ip":"0.0.0.0:2500",
    "source_width":1280,
    "source_height":720,
    "fpsnum":60000,
    "fpsden":1001,
    "aspectnum":1,
    "aspectden":1,
    "videomediatype":16,
    "audiomediatype0":2,
    "audiomediatype1":0,
    "audiochannelsinput0":6,
    "audiochannelsinput1":0,
    "audiochannelsoutput0":2,
    "audiochannelsoutput1":0,
    "audiosamplerate0":48000,
    "audiosamplerate1":0,
    "window_size":10,
    "segment_length":2,
    "hls_active":1,
    "dash_active":1,
    "video_codec":2,
    "video_profile":77,
    "video_quality":0,
    "source_interruptions":0,
    "source_errors":2,
    "transcoding":1,
    "scte35":1,
    "video_bitrate":10268000,
    "video_frames":13769,
    "outputs":1,
    "output_streams":[{"height":240,"width":320,"video_bitrate":1250}
]}

Clone this wiki locally