Friday, September 06, 2024

Accessing a Video Encoder via API

In this day and age APIs have become an integral part of connecting systems and data sharing. They function on both hardware and software providing a uniform way of communication. However, not every system (hard or software) facilitates an API, or although supported is known publicly. Recently I figured out a rather unexpected range of devices to possess a similar facility.


My workplace employs a few mid-range video encoders to provide live and on-demand audio/video streams to public platforms. They belong to a Chinese brand named “Digicast”. We use few encoders belonging to a couple of hardware versions, which in turn runs different firmware versions. My problem begins with having to manage these encoders and needing to enable/disable/reboot them daily or frequently.


Although Digicast’s firmware provides a simple web interface (with simple authentication), having to login to each device every time is troublesome. It is in this backdrop that I started researching on creating a simpler and efficient way of achieving the aforementioned tasks. For this, I had to provide instructions via a program, and for that, I needed an accessible API. Then one day, while I was checking the HTTP request/response headers to/from the encoders, there was an XML response to be seen. It contained several tags with values I was already familiar with (refer Image 1). This got me thinking, that if there is an XML response there should be a request mechanism (i.e. API access).

 

(Image 1)

 

However, countless searches on Google or any other search engine wasn’t fruitful. There is absolutely nothing on this on the web (I propose that you try). So I wrote to the company support and surprisingly they responded promptly. It took more than a couple of mails to make them understand my need and eventually they gave me an API documentation. Then, a dozen mails back and forth, and I had all I needed to proceed. I’ll be attaching the documentation for the “DMB-8900A Classic ProVideo Streaming Encoder” below, so that anyone could download and use it.

 

Now let’s take a look at some basic API calls and their purposes.

 

For example, following is a request to retrieve the current status of the encoder:
http://172.16.7.5/get_ctl?type=hdmi_ext 

You could read the XML output and search for the relevant tag/value to get the status of the stream. In my case, it would be <rtmp_second_enable> with a value of “0” or “1” accordingly. The documentation given at the end contains descriptions of other tags.

 

We could also give instructions to the encoder. For example, the following is for rebooting:
http://172.16.7.5/set_ctl?type=reboot

 

To enable/disable a stream, the value of “rtmp_enable” is set to “1” or “0” respectively:
http://192.168.5.5/set_ctl?type=hdmi_ext&rtmp_enable=1

 

Note the difference in the two end points “get_ctl” and “set_ctl” depending on whether you’re retrieving data or sending a command.

 

If you examine the attached document, there are plenty of other data you could retrieve using these API calls to accomplish your needs. I also must mention that API endpoints and parameters for later firmware versions may differ, and in that case, you’d have to get in touch with support and request the documentation. It’s rather surprising that the company hasn’t published this documentation online. It would make life easier for both their customers and support personnel.


[ API document ]