How to Share Videos with Your Friends Using IPFS - The Distributed Web. by powderskier

View this thread on steempeak.com
· @powderskier · (edited)
$0.04
How to Share Videos with Your Friends Using IPFS - The Distributed Web.
# How to Share Videos with Your Friends Using IPFS - The Distributed Web.
IPFS is the Inter-Planetary File System and allows you to share images, videos, and files with your friends in a distributed network. All files are stored based upon their *content* and not its *location* on the network. Read that again. Cool right?!?


![eos_developer_crew.png](https://cdn.steemitimages.com/DQmbjejNcVpgZtD8WbQAL4KG7DYJiHym2abn8hieWtwfhCZ/eos_developer_crew.png)

Here's a quick example on using the Inter-Planetary File System (IPFS) a distributed, peer-to-peer file system for sharing and data across the web.


## Requirements:
Download the IPFS [https://ipfs.io/](https://ipfs.io/) software. This let's you have access to the IPFS protocol.

## To get started: 
Open the IPFS daemon to connect with peers on the IPFS network.
```
~/repos/powderskier_posts$ ipfs daemon


Initializing daemon...
Successfully raised file descriptor limit to 2048.
Swarm listening on /ip4/127.0.0.1/tcp/4001
Swarm listening on /ip4/172.17.0.1/tcp/4001
Swarm listening on /ip4/192.168.1.117/tcp/4001
Swarm listening on /ip6/::1/tcp/4001
Swarm listening on /p2p-circuit/ipfs/QmU9c9xEwVeSMVpCXDiKZRc4TKyxriG489qUY5TYVRmuP9
Swarm announcing /ip4/127.0.0.1/tcp/4001
Swarm announcing /ip4/172.17.0.1/tcp/4001
Swarm announcing /ip4/192.168.1.117/tcp/4001
Swarm announcing /ip6/::1/tcp/4001
API server listening on /ip4/127.0.0.1/tcp/5001
Gateway (readonly) server listening on /ip4/127.0.0.1/tcp/8080
Daemon is ready
```
* Cool, we are connected to the IPFS network. Leave this terminal running and open a new terminal session for the next sections below.

## Upload your video to IPFS
Let's now upload the video <launch_night.MOV> to IPFS so that we can share it with friends. I'll share the video of the EOS developer's party from San Fransisco when the Mainnet launched.
```
~/repos/powderskier_posts$ ipfs add -r eos_launch_night/
added QmXwDyxYu2SPveibXMShkz1C7grmANk5vd6Z9mFrXsVKvE eos_launch_night/eos_launch_party.mp4
added QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV eos_launch_night
```


As you can see above, there was a unique hash created for the <eos_launch_party.mp4> file (QmXw....) and a second hash ( QmZP...) points to the folder EOS_Launch_Night/ where the file resides. The second hash is like the address on a mailbox on a global mailing system. It is unique to the person who published it (see [IPNS](https://medium.com/@yaniv_g/hosting-websites-on-ipfs-with-ipns-b94659c42b52) for more details). It's a lot like a pointer in C.  If we want to share the pointer of this folder with our friends, we just sign it with one of the keys from our accounts and publish that to IPFS
```
~/repos/powderskier_posts$ ipfs key list
self
@bob
@bob.to.sue
@sue
eos_videos
```
## Publish the Video to the Distributed Web
We will use the eos_videos key to publish the folder to IPFS.
```
~/repos/powderskier_posts$ ipfs name publish --key=eos_videos QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV
Published to QmNctNgLivXpXPMSc8X943bJRG25u1XAuW9yyzutbrdFTP: /ipfs/QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV
```

## See if you can view the file on the web at:
<https://ipfs.io/ipfs/QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV>

When I try this, I can see that the eos_launch_party.mp4 folder is accessible via the web, but the download is super slow and just hangs. Why does it take so long? I just tried to republish it so let's see it that helps. Does the file download for you?


## How to Download the File From the Web
Let's simulate a remote download of the movie and see if we can play. We use `$ ipfs get /ipfs/<HASH>` to pull the data from the distributed web. Could you try this as well and see if you can get the movie file? Sometimes IPFS it tough to use and I'm trying to iron that out so please provide feedback and let me know if this works or doesn't work for you :). If we can get this system working together - say goodbye to paying for cloud storage!
```
~/repos/powderskier_posts$ cd ..
~/repos$ cd
~$ cd Videos/eos_party/
~/Videos/eos_party$ ls
~/Videos/eos_party$ ipfs get /ipfs/QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV
Saving file(s) to QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV
 2.33 GB / 2.33 GB [============================================================================================================] 100.00% 2m27s
```

## Open the Download
Looks like the download worked. Let's look at the video and see if we can view it. Navigate to the parent directory of the eos_launch_party.mp4 file and open it.
```
~/Videos/eos_party$ ls
QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV
~/Videos/eos_party$ cd QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV/
~/Videos/eos_party/QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV$ ls
eos_launch_party.mp4
```

## Open the video file. 
I was able to open and view the <eos_launch_party.mp4> video file and it still had nice quality. (I actually compressed earlier from a 6GB .MOV file to 1GB .mp4 file using ffmpeg. Ping me if you want a tutorial on that.) So here's the video!
![eos_developer_crew.png](https://cdn.steemitimages.com/DQmbjejNcVpgZtD8WbQAL4KG7DYJiHym2abn8hieWtwfhCZ/eos_developer_crew.png)

## Summary: 
We just learned how to:
* Add files and folders to IPFS using `$ ipfs add -r FOLDER/`
* Publish this content to the distributed web, using `$ ipfs name publish --key=XXX FOLDERHASH`
* Pull content from the distributed web using `$ ipfs get /ipfs/HASH$`

IPFS Rocks, Right?!! The web 3.0 is going the distributed. Let's all do our part to support projects that empower this movement. If you like these tutorials, please tell me what you enjoy or would like to see and I'll do that next time. :P

Cheers,
Gunnar
👍  , , ,
properties (23)
post_id53,053,005
authorpowderskier
permlinkhow-to-share-videos-with-your-friends-using-ipfs-the-distributed-web
categoryeos
json_metadata"{"image": ["https://cdn.steemitimages.com/DQmbjejNcVpgZtD8WbQAL4KG7DYJiHym2abn8hieWtwfhCZ/eos_developer_crew.png"], "links": ["https://ipfs.io/", "https://medium.com/@yaniv_g/hosting-websites-on-ipfs-with-ipns-b94659c42b52", "https://ipfs.io/ipfs/QmZPWT6chRfbzZtMCHbCJUbWj9v18zDP3xZSnjZdTLqbTV"], "tags": ["eos", "ipfs", "distributed", "technology", "freedom"], "app": "steemit/0.1", "format": "markdown"}"
created2018-06-15 01:24:39
last_update2018-06-16 00:17:18
depth0
children0
net_rshares0
last_payout2018-06-22 01:24:39
cashout_time1969-12-31 23:59:59
total_payout_value0.035 SBD
curator_payout_value0.008 SBD
pending_payout_value0.000 SBD
promoted0.000 SBD
body_length5,691
author_reputation81,491,274,690
root_title"How to Share Videos with Your Friends Using IPFS - The Distributed Web."
beneficiaries[]
max_accepted_payout1,000,000.000 SBD
percent_steem_dollars10,000
author_curate_reward""
vote details (4)