henry-rodrick / hlsjs-ipfs-loader

A js-ipfs loader for the hls.js JavaScript HLS client
MIT License
60 stars 31 forks source link

Video not loading? #3

Closed whydna closed 6 years ago

whydna commented 6 years ago

Hello friends,

I'm trying to get this demo working and I'm running into an issue where now the video does not load.

You can see the demo here: https://ipfs.io/ipfs/QmZ5wo4SsKfiz1KotxeCpvHw7PQ1wnhrihgSL2rR4E1jPP/

There are no JS errors, and it seems to be able to find the playlist/manifest file and start trying to fetch the first segment but is never able to play it. Oddly enough, if I swap out the playlist hash for the BigBunny one in this sample https://github.com/ipfs/js-ipfs/tree/master/examples/browser-video-streaming it works.

So I suspect it has something to do with the file I uploaded or my IPFS daemon? I ran the same FFMPEG command in the link above to segment the video, and then did an IPFS recursive add. The video segments and playlist can be seen here: https://ipfs.io/ipfs/QmQNStJCTJkZtADSkCf7fWKcTsdaqV7xz6Qox1u51rY99m. I also have the IPFS daemon running on my laptop so it should be serving the files.

Any thoughts on how to debug?

henry-rodrick commented 6 years ago

Oh it's just the IPFS Kanye blocker! :p

Seriously tho, works for me now, but only after requesting the manifest and all the segments through the ipfs Gateway first. I think there are limitations at the moment in ipfs-js where only secure websocket peers can be connected to (the ipfs.io gateway runs both protocols, so by "warming up" a gateway node you make those files available to js-ipfs as well). This limitation should go away in the future, but I've not had time to follow the js-ipfs development closely for some time so I'm not sure where they're at with this. I'd recommend asking about this in #ipfs on IRC (freenode).

Cheers

whydna commented 6 years ago

Hahah. It eventually loaded for me as well!

False alarm.

henry-rodrick commented 6 years ago

Well, it loaded because the gateway was manually "warmed up".

But one thing you can do for now though -- if you have websockets on your ipfs node where you added the content -- is to use the swarm API and explicitly connect to that node from js-ipfs (i.e adding it to the swarm by its address). It should be described in the js-ipfs API docs, but again, ask on IRC if you get stuck as they're generally very helpful :)

whydna commented 6 years ago

Thanks for the tip @moshisushi - I'll give it a try.

Quick question - what are the benefits of running a node in JS as opposed to just going through the IPFS.io gateway/API? (i.e just setting the source as https://ipfs.io/ipfs/playlist_hash ?

henry-rodrick commented 6 years ago

The gateways are set up by the IPFS core developers and are only there for testing/demonstration etc. Generally speaking, there shouldn't be any gateways where all traffic has to go through (because then it's not a very distributed system at all). Ultimately the gateways shouldn't be needed at all, but a temporary step for now if you want to avoid having to through them (and warm them up manually with your content) is to point js-ipfs directly at your own peer.

I think the things that will solve this ultimately is something called ipfs-circuit (a protocol bridging mechanism) and also a DHT implementation in js-ipfs. Again, not sure about the current progress of those projects but I'm sure they're happy to chat about it if you ask :) hope that helps!

whydna commented 6 years ago

Amazing. Makes perfect sense - thank you for clearing that up for me.