Building a live-stream archive with Amazon Interactive Video Service

How we incorporated the new live-stream recording feature in IVS into our own live event platform

Amazon Interactive Video Service (IVS) is a fully managed live streaming service that makes setting up the infrastructure for a live stream as simple as a few API calls or clicks. We like it because we don’t have to care about infrastructure, video quality, and delivery. So we used it in our live streaming web platform. We made our platform so that our clients in retail can have an easy interface to set up and share live events. With the platform, they can add purchasable products to events, and choose in real-time to present these products to users during the event. For these clients, live streaming is an opportunity not to be missed — yes, for getting purchases from the events but also to develop richer relationships with their customers.

One thing that we did not offer until recently was the ability to record these streaming video events for viewers to watch later. Without this, viewers can’t come back and view earlier streams whenever they want and our clients don’t get to continue to benefit from their continued engagement with the products and the event.

In order to provide this recording ability, what we might have done is build an additional layer between the live streamer and IVS, but the potential impact on complexity and latency of doing this meant we were not keen to go down that route. We thought it prudent to wait for Amazon to put recording functionality directly into IVS — and now they have.

We’ve been using the IVS stream-recording pre-release feature for a few weeks now, and thought our experience worthy of sharing. So let’s first briefly describe how IVS enables recording of live streams and then how we incorporated it into our platform.

IVS live stream recording

It works like this: by selecting the ‘Auto-record to S3’ option when setting up an IVS ‘channel’ any video content streamed to the channel will automatically be stored in S3 at the same time as being streamed by IVS in real-time to all viewers as usual.

Recorded videos are persisted in the HLS format, which is a subset the LHLS format used to stream with low-latency to live IVS viewers, and any metadata sent with the stream is also captured. This makes it easy to replicate the live-stream experience for viewers of the recording and we don’t need to do any extra post-processing like we have to do when our users upload their own videos.

Recording and distributing live stream events

So this is how that live streaming gets integrated into our platform: when the recording of a live stream is complete, IVS fires a ‘Recording Ended’ event into Amazon EventBridge. Our back-end reacts to this event by doing the following:

  • Taking the recording and pushing it to Amazon CloudFront where we can serve it efficiently together with our other static web content (HLS is designed around HTTP so perfect for distribution networks like CloudFront).
  • Updating our web platform’s database so that the live video is discoverable and all its relevant data is filled out (for example, thumbnails and product information).

Since we are using Django hosted in Amazon’s Elastic Container Service (ECS) as the basis for our web platform, we decided the most straight-forward way to handle these EventBridge events was to re-use all that — the container, the ORM, the application code — and fire ECS “scheduled tasks” in response to the EventBridge events. That is, we use short-lived ECS tasks that exists just to handle pushing the recording to the right place and update the database. We could have used AWS Lambda for this, but by using ECS we were able to re-use a lot of existing functionality, environments and settings. The main complexity introduced by going this route is around setting up and debugging the interaction between EventBridge and ECS tasks.

How we use IVS stream recording with our Django app on ECS. The beautiful stuff happens in the “load recorded event task”.

The recorded video served from CloudFront is compatible with the same IVS player (based on video.js) that we use for playing live video in the browser, so our existing UIs don’t require any updates to play recorded streams.

A fully-fledged live streaming event platform

To sum up what we have now: IVS gives us the live-streaming service that we need as the basis for a fully-fledged live streaming event platform. We get to offer our clients the ability to create, administrate, and conduct live-streaming events, with products streamed down to users in real-time. Beyond live streaming, we offer the following features to our users right now:

  • Event profiles with thumbnails and associated product information to make the events discoverable and interactive.
  • Highlighting of products to viewers in real-time, with viewers able to click the product and start the purchase process.
  • Uploading of pre-recorded video-on-demand with an interface for inserting timed product data.

With the following features not far away:

  • Viewer-host two-way interactions and chat to keep the event as participative and engaging as possible.
  • Shopping cart and checkout integration to reduce friction in the purchasing process and remove the line between the live-stream and the user’s own online shopping experience.

Conclusion

We had liked how fast we were able to develop our streaming video platform with IVS but the recording was really the most important missing feature till now, so it was good to see how straightforward it was for us to bring it in. And we liked our solution of using ECS scheduled tasks to wrap up our application code for use with recording events coming through from IVS. We hope you steal the idea!

We’re always happy to talk about cool stuff we’ve done so feel free to get in touch.

 
Back to Blog