The Paratii.JS Developer Preview

Paratii
Paratii
Published in
7 min readApr 25, 2018

First glimpse of an open source peer-to-peer streaming engine & JavaScript library for video-powered dApps.

TL;DR: we released a developer preview of Paratii.JS, which is currently being used on IPFS + a permissioned Ethereum testnet. Check its GitHub; download the package via npm; read through the documentation; skim over some simple ideas for hacks or watch a brief walkthrough.

What is Paratii.JS?

A library any developer can use to put a video stream and get a playable url for it, while it gets ingested, stored, transcoded and distributed behind the scenes, all through non-centralised means. With this, one can easily build out-of-the box decentralisable video-powered web applications. Paratii.JS has early functionalities for handling tokens too, meaning one will soon be able to use it to set monetisation models for videos, collect earnings, participate in curation, and else.

Why did we spend energy on this?

Over 2 billion people watch online videos, every month, around the world. The medium grows exponentially. Manipulating video on the web has become easy after HTML5 and the <video> tag (along upper-level abstractions like Video.js). However, streaming remains complex.

The old Flash warning, and Steve Jobs’ historical thoughts on it. Openness was the first point in the critique.

We see moving images on online news outlets, distance learning courses, sports’ broadcasts… but hardly ever wonder where these images have been through before arriving at our browser.

Jeff Bezos called this the “undifferentiated heavy lifting”, in the early days of AWS. As per an old (2006) blog post, it refers to

“server hosting, bandwidth management, contract negotiation, scaling and managing physical growth, dealing with the accumulated complexity of heterogeneous hardware, and coordinating the large teams needed to take care of each of these areas”.

All the “heavy lifting” can be encompassed in a generic 7-step process, and each part of it has grown in complexity over the last decade. The market dominance of those who master the flow is also on the rise, as one would expect. We once heard a large (~20%) share of Amazon’s transcoding services revenue came from Google itself, which needed to outsource the processing for some of the monstrous amount of content Youtube got. The anecdote may be false, but the point remains: it’s just impractical to compete with the big oligopolies in economies of scale, when it comes down to streaming.

Without getting into nitty-gritty details, for many small- to mid-sized publishers, distributing online video simply becomes more costly than what it earns back. But one simply must keep doing it to maintain an audience while making money elsewhere.

We believe that technologies that put value capture in the hands of true content producers (and not rent-seeking intermediaries) have undergone robust evolution through the past two or three decades, and are now on the verge of altering the market landscape of video distribution for good. This will likely happen under the convergence of three non-traditional paradigms, which Paratii adheres to: peer-to-peer, open source and crypto-incentivisation.

Above, the generic 7-step video streaming pipeline. Below, Amazon’s and The New York Times’ own versions of it.

How to develop with Paratii.JS?

Check out its official documentation, GitHub repository and simple tutorial.

There is a webpack minified browser build to be used directly in your web pages, or you can use paratii.js as a package in your Node.js application.

After you require the Paratii object and set default/custom config + your account, you’re ready to go.

Paratii = require(‘paratii-js’)
let paratii = new Paratii()

Your newly configured paratii object can now read data from the blockchain. For example, you can search for videos about cats:

let catVideos = await paratii.vids.search({keyword: 'cats'})

Which will return a paginated set of results. For publishing a video, we provide a convenience function with a simple interface:

paratii.vids.uploadAndTranscode( {
title: 'My video',
file: '/tmp/myvideo.mp4'
})

The semantics of this is straightforward: it will publish the video in /tmp/myvideo.mp4 to the Paratii “cloud”. The function will return immediately an eventEmitter instance which will report about progress (and eventual errors) in the process, along with a promise that resolves with the multihash for the ready-to-stream video. The pattern of returning a promise combined with an eventEmitter will be recognisable for those familiar with web3.js.

Below is a short commented walkthrough on the library’s main modules and methods:

Hooray! This video was published through Paratii.JS, and is being streamed over IPFS, through the Paratii Player. If you play it, your browser will become an ephemeral node in the underlying p2p network.

What can one #buidl with it?

While the code works, it’s still unusable on the Ethereum mainnet. Primordial scalability issues (when it comes to public chains) are intentionally unaddressed, and no external security audit has been conducted. There is a lot of work ahead until this becomes a viable system.

However, the core functionality for prototyping applications around decentralised video is implemented. Thus, it made sense to push this preview forward and give developers a chance to get familiar with the library. We hope they will check it out, experiment / prototype, report bugs and help us improve on the way towards a mainnet beta release candidate.

One will find functions for writing information about videos and ownership to Ethereum, uploading and fetching videos over IPFS, requesting and receiving the result of transcoding jobs, besides accessing a blockchain index that allows for reading and querying information.

There’s a bunch of simple ideas for hacks here, if you’re looking for inspiration. They range from a simple web-interface for mirroring videos from another network to a Toshi-based bot for tipping creators of videos you receive via chat.

Do I need tokens? When will it be ready™?

You don’t need any tokens to use the library and take advantage of most of its functions (for instance: staking-specific functions will still, of course, require tokens). In production, some baked-in monetisation options that depend on Paratii’s token-curated registry will prompt staking in order to work. You’ll still be free to use the library without tokens or to build whatever interface on top of it.

Although the code is miles away from being production-ready, it’s already useful in many senses. Check out this simple web demo for an idea of what can be done pretty much out-of-the-box. The library is being updated as the token-curated registry behind Paratii evolves in its implementation, and we will incorporate monetisation features in it along the next months — for those looking for a competitive, cost-effective solution to distribute video to millions of users, this will likely not be there until at least next year.

Notes on agnosticity & further steps

The idea of an open streaming engine revolves around modularity. Ideally, we won’t have IPFS/libp2p “hooked in” as the sole storage solution for files, but rather offer interchangeable Swarm/Storj/[insert your own]-based video persistence. We currently provide some “custom” transcoding nodes for use, but are in the process of integrating Livepeer to experiment with their transcoding protocol and network. Here, too, having something like a wrapper (akin to Snickers, built by our advisor Flávio), that chooses among the most adequate provider for each job request, is the end we aim towards (e.g. a more expensive and faster service for live/breaking news; something cheaper and slower for old documentaries; a specific one for VR). Live video streaming is also an upcoming feature, with a single call giving an endpoint where one can push a live stream and get an ID to play it back.

Reaching the desired level of interoperability with sister networks, in production, will likely involve using 0x for token abstraction, which is one reason why we’ve been eagerly exploring uses of the decentralised exchange protocol. As you may be thinking, this is not a vision that will unfold completely in the short-term. We’re building technology for the long-run.

Last, but not least, Ethereum clients do not offer much functionality for searching and indexing, so we defined an API and coded a REST service that indexes the data on the blockchain and IPFS. This index is part of a replicable package that encompasses also a transcoding node and an IPFS gateway. We run some of these ourselves, and are in the process of making the software straightforwardly available for anyone that voluntarily wants to join the network this way. As for rewards and incentives, please bear with us until our protocol specifications are finalised and public.

We’re excited to share this library with the community and to start developing it in the open. Your feedback and contributions are eagerly appreciated. For ongoing updates, follow Paratii on Twitter!

Paratii is building a peer-to-peer network for curation and monetisation of videos.

We’re on reddit, and the team is accessible through Telegram (BR here 🇧🇷, EN here 🇺🇸). Don’t hesitate to get in touch via email, or👇

Huge kudos to Jelle, Yahya, Enrico, Elia, Ben and Lorenzo for all the wizardry ✨

--

--

Paratii
Paratii

Decentralised video, before it went mainnet.