Sitemap

Open Source Newsletter #002

3 min readNov 4, 2021

--

In the monthly Eyevinn Open Source Newsletter we present the latest updates and additions to our libraries, tools and components that we have made available as open source.

HLS Recorder Library

A NodeJS library for recording HLS live streams. This library can for example be used when building a service that consumes an HLS live stream, downloads and copies the media segments.

const { HLSRecorder } = require("@eyevinn/hls-recorder");
const sourceUrl = new URL("<URL to LIVE HLS>");
const recorder = new HLSRecorder(sourceUrl.href, {
recordDuration: -1,
});
recorder.on("mseq-increment", mseq => {
// Do stuff...
console.log(mseq);
});
recorder.listen(8000);
recorder.start();

Create an HLSRecorder instance and provide the URL to the live HLS source. Register a handler that is called on each media sequence update. In this handler you could put work on a job queue. A queue consumed by a downloader for example.

HLS Proxy Library

There are a number of use cases where HLS manifest manipulation techniques are applicable. Multi CDN switching, server-side ad insertion, looping or truncating a VOD, to mention a few. The fundamental principle is that you need some HLS proxy between the video player and the original HLS you wish to modify somehow. As this is a very common component in all these use cases we have developed and open sourced an NPM library, hls-proxy, that takes care of that.

Example of in-stream CDN switching using this hls-proxy library:

const { HLSProxy } = require("@eyevinn/hls-proxy");

const cdnSelector = () => {
// Make decision on which CDN that is best to use here
return "https://maitv-vod.lab.eyevinn.technology";
};

const proxy = new HLSProxy({
originHandler: async () => {
return cdnSelector();
},
segmentRedirectHandler: async (request, baseUrl) => {
const redirectUrl = new URL(request.raw.url, baseUrl);
return redirectUrl.href;
}
});
proxy.listen(8000);

// Example: http://localhost:8000/VINN.mp4/master.m3u8

Find more code examples and use cases in this blog post on our developer blog.

Eyevinn Schedule Service

Whether you are developing a frontend application for a streaming service presenting an EPG, or building services to generate linear channels (virtual or real) you might need some realistic schedules for testing. With realistic schedules I mean a schedule that contains events timed with the time-of-day and the length of the content. For this purpose we have built the Eyevinn Schedule Service and also released the source code as open source.

Press enter or click to view image in full size

Our demo channel on the Channel Engine demo page is connected to a running instance of this service. In this blog post we describe this service and how to use it in more detail.

Ingest Application Framework plugins

The following new plugins are now available that can be used in your ingest application based on our ingest application framework.

HLS Duration

A small but convenient library to calculate the duration of an HLS by calculating the sum of the segment durations.

const { hlsduration } = require("@eyevinn/hls-duration");hlsduration(new URL("<VOD URL>")).then(duration => {
console.log(duration);
});

Follow us on Instagram where we post inspiring code examples and share our knowledge. Below code snippet gives you an example on how to on-the-fly stitch a bumper to an HLS VOD.

Press enter or click to view image in full size

Eyevinn Technology is leading specialists in video technology and media distribution, and proud organizer of the yearly nordic conference Streaming Tech Sweden.

--

--

Eyevinn Technology
Eyevinn Technology

Written by Eyevinn Technology

We are consultants sharing the passion for the technology for a media consumer of the future.