Bringing easy to use operations in the world of streaming
I have been a found supporter of APIs for more than a decate. During the early days I wrote APIs to allow partners to fetch data from my price comparison site and therefore integrating services to others. This happened around 2005.
Recently I joined Eyevinn Technology as a solution architect focusing on infrastructure and operations when it comes to OTT services. One of my missions include automation and Scott Hanselman said it well:
“The most powerful tool we have as developers is automation”
On that theme I wanted to explore the option to integrate video encoders with the cloud and the popular collaboration tool Slack. As a proof of concept I’ve decided to pull running events from an Elemental Live encoder running in our awsesome lab that my colleague @JonasBirme has been talking about in a few posts:(https://medium.com/@eyevinntechnology/our-streaming-lab-setup-on-aws-8cf4bf5fd9e3)
This example shows how it’s possible to pull live data from a running event on an Elemental Live encoder and publish that into a slack channel. As you can imagine this is just a bot (with code) listening on specific events and is able to take actions. The action I’m showing here are listing live events and their runtime together with the events input.
To get us started we need to create a slack bot. That can easily be done at https://my.slack.com/services/new/bot. The only information needed to run the bot would be a API key for that particular bot you’r creating. I’ve created the following bot at Eyevinns slack account, of course with a reference to Matrix…
Once the bot was created we needed to find a way to integrate with the slack bot. As slack is a real time communications platform most interactions with their API is done over Web Sockets. That allows for bi-directional communications and, based on my experience is super-fast. My library of choose would be the PHP Slack Bot class (as I have developed php applications for some time) that can be found at https://github.com/jclg/php-slack-bot. Adding a library in php is mostly done i “composer” that would be the equivalent of NPM for you who runs node.
As we need web sockets php will be depending on react library that contains socket communications and a bunch of other classes. Once installed we’ll create a server that talks to Slack and is able to listen to communications on a specific channel. In this example we will not customize the blog, but rather showing what could be done. We will listen to all communications in the channel but only act on specific events. In particular we are monitoring the following:
All slack channel posts about “Elemental status” (case sensitive) would trigger a function call in our web sockets server.
As we have the Slack integration done and the next step would be to talk to our Elemental live server. As we are using our cloud based (AWS) encoder we are required to authenticate and talk to Elemental Conductor. That would require some extra steps to generate tokens. Luckely the process is the same as if you’r running an on-prem installation that would require username and password for authentication (the default installation does not) and is well documented at http://cloud.elementaltechnologies.com.
I do not want to go into details about how the process is done, but elemental includes example scripts in ruby and phyton, that I’ve converted into PHP. Elemental, much like slack do require API key(s) as part of their authenticate process.
Once done you can start asking for events. Elemental offers the “/live_events” API that lists all running events. That can feed another call to a specific event just by adding the event ID to the same call above.
That way I’m able to loop thought all running events, including events that has completed but are still at a running state.
The above show a slack channel at Eyevinn listening a “live-on-tape” event beeing encoded from a S3 bucket and packetized into HLS and DASH.
Once the event has finished the status can be updated as seen below.
The above shows the most simple example of an integration between online DevOps tools and traditional OTT hardware.
In real life this can simplify operations for various taks. For example we could broadcast (into slack) when an event has stopped, input is lost or if the encoder is not able to push (for example HTTP POST) segments to a origin. An operator could easily verify that and issue a restart of the stream, all within slack. There are a number of use cases here.
If you want to know more about this or just want to connect with me you can find me on Twitter (@sir_anders) or in our Streaming Tech Sweden community on Slack where you also will find some of my colleagues.
Anders Johansson is a Solution Architect at Eyevinn Technology. A Swedish consultancy company specialized in streaming, VR and gaming.