[IPFS Tutorial #4] - Upload and Stream Videos via IPFS

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@hsynterkr·
0.000 HBD
[IPFS Tutorial #4] - Upload and Stream Videos via IPFS
![](https://steemitimages.com/0x0/https://ipfs.io/ipfs/QmTgtbb4LckHaXh1YhpNcBu48cFY8zgT1Lh49q7q7ksf3M/raster-generated/ipfs-logo-text-512-ice.png)
>[source](https://ipfs.io/ipfs/QmTgtbb4LckHaXh1YhpNcBu48cFY8zgT1Lh49q7q7ksf3M)

#### Repository
https://github.com/ipfs/ipfs

#### What Will I Learn?

- You will learn how to upload a video to IPFS
- You will learn how to stream a video from IPFS
- You will learn how to build a NodeJS app to stream videos via IPFS

#### Requirements

- [IPFS](https://ipfs.io/docs/install/)
- [NodeJS](https://nodejs.org/en/)
- Simple Javascript Knowlegde

#### Difficulty

- Intermediate/Advanced

#### Uploading Videos to IPFS
In the [previous tutorial ](https://utopian.io/utopian-io/@hsynterkr/ipfs-tutorial-2-build-a-nodejs-app-for-ipfs) I showed how to upload images or videos to IPFS. You can upload it by following the tutorial. 
To upload a file to your IPFS server, you must make an HTTP POST request to the server. a key whose value is a video file in the body of request must be defined.
![image.png](https://gateway.ipfs.io/ipfs/QmdGGDMQApkB22vGx6Yyug9Dfj113wJrQQ2Ku3qLX41sNx)

Now I will upload **Utopian.io - How to Contribute**  video to my IPFS server with Postman.

![image.png](https://gateway.ipfs.io/ipfs/QmPEZZSp6euSczdRmKFcwwFk525ZGJ8WC3eBKMaQKNaD1H)

>Successfully uploaded!
````
https://steemia.net/ipfs/QmPfeq2wm79gS5Ho4Jyasu5TLSoSewfs41kxLpGKiSRr6w
````
#### Streaming Videos from IPFS 
When you send an HTTP POST request, it will return the HASH of the file. When you send an HTTP POST request, it will return the HASH of the file. With this Hash you can access video via IPFS Gateway.

````
https://gateway.ipfs.io/ipfs/HASH

````

![image.png](https://gateway.ipfs.io/ipfs/Qmbtj3PmWaerphaSbM9pEPc8QXEA7UZCucSkC7jZaQaTj5)

#### Streaming Videos from IPFS with **video.js** Library
You can create an interactive video player with the video.js library to play the videos. [Video.js](http://docs.videojs.com) is an extendable library around the native video element.

![image.png](https://gateway.ipfs.io/ipfs/Qmf7vn4hTQoFh4hjvMTP7idmyP9S5bXx35ZejJRhd9i6TM)

- How does it look now?


![image.png](https://gateway.ipfs.io/ipfs/QmQUHJX9XXqyJPLQqateph7yjDYGy31hvjNb6KmfYcoXR8)


##### Build a NodeJS app to View Videos
Let's start by creating an application with NodeJS starter pack.
Once you have created a NodeJS app, you will create two html pages for homepage and video review page. On the Index page, the user will enter the video hash and the video will be opened in a new page with the VideoJS player.

>index.js

![image.png](https://steemia.net/ipfs/QmReCPw9s2UWt9pgFcoec7HCQnpVgudG2ZmX9qz6V83SLt)

>index.html

![image.png](https://gateway.ipfs.io/ipfs/QmfNMrZGMEAFx45pSj68D4TbVCruDWPjroLNYzYZ3wKCFi)

>video.html to render videos

![image.png](https://gateway.ipfs.io/ipfs/QmeRWUyeBoQnFmofALENpVGRmY5iwa9XZBPQWvmWmhCfnE)

##### Synopsis
When you open to Home, an input will ask for Video hash. When you submit a video hash, you will access the video via the ipfs gateway, and video.js will be triggered to play the video. 

I also deployed this nodejs application so you can easily test it. I uploaded Utopian Contribution Tutorial video to IPFS. You can use it to test video-ipfs app.

````
QmPfeq2wm79gS5Ho4Jyasu5TLSoSewfs41kxLpGKiSRr6w
````


>https://ipfs-tutorial.herokuapp.com

<hr>

![gif](https://media.giphy.com/media/8w3m1SrRRXZJ9iHVHS/giphy.gif)

#### Curriculum

- [[IPFS Tutorial #3] - Using the IPFS Command Line Interface](https://utopian.io/utopian-io//@hsynterkr/ipfs-tutorial-3-using-the-ipfs-command-line-interface)
- [[IPFS Tutorial #2] - Build a NodeJS app for IPFS](https://utopian.io/utopian-io/@hsynterkr/ipfs-tutorial-2-build-a-nodejs-app-for-ipfs)
- [[IPFS Tutorial #1] - Host Your Images Online Forever with IPFS](https://utopian.io/utopian-io/@hsynterkr/host-your-images-online-forever-with-ipfs)

#### Proof of Work Done

https://github.com/hsynterkr/video-ipfs
👍 , , , , , , , , , , , , , , , , , , ,