Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Streaming video using js-ipfs in the Browser #965

Closed
milankragujevic opened this issue Aug 27, 2017 · 12 comments
Closed

Streaming video using js-ipfs in the Browser #965

milankragujevic opened this issue Aug 27, 2017 · 12 comments
Labels
kind/support A question or request for support P1 High: Likely tackled by core team if no one steps up

Comments

@milankragujevic
Copy link

milankragujevic commented Aug 27, 2017

  • Version: 0.25.2
  • Platform: macOS 10.12.6 Chrome 60.0.3112.113
  • Subsystem: Not sure?

Type:

Question

Severity:

High / Critical (sometimes)

Description:

I cannot seem to get js-ipfs communicating with go-ipfs... I get cryptic errors, and I'm not quite sure is that even supposed to work. My code is this:

const ipfs = new Ipfs({
  init: true,
  start: true,
  repo: 'ipfs-testing-' + window.reqID,
  config: {
    Swarm: [
      "/dns4/milankragujevic.com/tcp/9999/ws",
      "/libp2p-webrtc-star/dns4/star-signal.cloud.ipfs.team/wss"
    ],
    Bootstrap: [
      "/dns4/ams-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLer265NRgSp2LA3dPaeykiS1J6DifTC88f5uVQKNAd",
      //"/dns4/sfo-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLju6m7xTh3DuokvT3886QRYqxAzb1kShaanJgW36yx",
      "/dns4/lon-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLMeWqB7YGVLJN3pNLQpmmEk35v6wYtsMGLzSr5QBU3",
      //"/dns4/sfo-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLnSGccFuZQJzRadHn95W2CrSFmZuTdDWP8HXaHca9z",
      //"/dns4/sfo-3.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLPppuBtQSGwKDZT2M73ULpjvfd3aZ6ha4oFGL1KrGM",
      "/dns4/sgp-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLSafTMBsPKadTEgaXctDQVcqN88CNLHXMkTNwMKPnu",
      "/dns4/nyc-1.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLueR4xBeUbY9WZ9xGUUxunbKWcrNFTDAadQJmocnWm",
      "/dns4/nyc-2.bootstrap.libp2p.io/tcp/443/wss/ipfs/QmSoLV4Bbm51jM9C4gDYZQ9Cy3U6aXMJDAbzgu2fzaDs64"
    ]
  }
})

ipfs.on('error', (err) => {
  console.error(err)
})

ipfs.on('ready', () => {
  ipfs.files.cat('QmcPZGXSyaQSnDVEtJrgtp2EyxhENiBdpGa8pfs5rMBCWr').then((data) => {
    window.VideoStream(data, document.getElementsByTagName('video')[0])
  })
})

I built the latest 0.25.2 version with gulp and set it up but it doesn't seem to work, I usually get no response or this:

Error: Stream ended prematurely

You can see it in action here at the link below.

I'm trying to stream Sintel.mp4 from WebTorrent, which I know for a fact should work, using the package videostream, as WebTorrent uses, and this usually works with HTTP-storage and a custom API for loading data via AJAX, or via vanilla WebTorrent, but doesn't seem to work with js-ipfs. I'm not sure whether the problem is with videostream or with js-ipfs, but I'm leaning more on the js-ipfs, because it seems to never even try to execute videostream.

Thanks!

Steps to reproduce the error:

https://milankragujevic.com/ipfs-proj/

@daviddias
Copy link
Member

Thanks for reporting this, @milankragujevic. We are investigating a possible regression in the WebSockets transport (either in js-ipfs or go-ipfs side //cc @lgierth).

Meanwhile, check the work developed by @moshisushi on #128 and #947, he built a HLS Video Streamer using js-ipfs and his demo is fully working.

Btw, this seems like an excellent test for js-ipfs, would you like to consider adding it to the batch of tests? Thank you!

@daviddias daviddias added status/ready Ready to be worked kind/support A question or request for support labels Aug 28, 2017
@daviddias
Copy link
Member

Hey @milankragujevic, check if https://github.com/ipfs/js-ipfs/tree/master/examples/browser-video-streaming is helpful to you. Thanks to @moshisushi for making it happen!

@daviddias daviddias changed the title How do I actually stream video from go-ipfs on the server to js-ipfs in the browser? Streaming video using js-ipfs in the Browser Sep 1, 2017
@daviddias
Copy link
Member

btw @milankragujevic, your issue is because you are passing a Stream object to a thing that expects a buffer. You need to buffer up the stream.

You can do that manually or just use bl

@milankragujevic
Copy link
Author

The problem was that the code inside the function NEVER got called, so it doesn't even matter.

@daviddias
Copy link
Member

@milankragujevic test with the latest master, that was due to infra changes that separated bootstrappers from gateways, it was fixed with #973

@OstlerDev
Copy link

I downloaded milankragujevic's demo app, built the latest master and swapped it in, but it still doesn't seem to work.

It would be very helpful to get an example made for the native html5 video player, and VideoJS once this works though.

@milankragujevic
Copy link
Author

@OstlerDev Hi, I actually got it to work, you can see it here, thought it's not for distribution yet, that's why there's the warning in the footer.

https://milankragujevic.com/ipfs-proj2/

@OstlerDev
Copy link

Very interesting and cool, I will be watching and waiting until there is a stable version to start testing with.

Glad to see you got it working!

@NinjaTurtle007
Copy link

So when realistically we can have working p2p live video streaming?
And would it work for users that share IP, are behind NAT or have dynamic IP?

@victorb
Copy link
Member

victorb commented Sep 27, 2017

@NinjaTurtle007 there is currently two threads in discuss.ipfs.io about live (or not) streaming.

Copy paste from those:

Here is a tiny proof of concept for webcam streaming between multiple peers. It's inefficient since it sends the data directly to each peer, instead of sending a hash identifying the content then helping everyone pulling it down. But it works.

Repository: https://github.com/victorbjelkholm/resort
Demo: https://ipfs.io/ipfs/QmaK1BRzvYU7F2taQ5qAazKKDGqSgZ9vu2vSYyw1L852ws/

@daviddias daviddias added the P1 High: Likely tackled by core team if no one steps up label Oct 17, 2017
@daviddias
Copy link
Member

Let's convert this thread into a thread on https://github.com/ipfs/research-p2p-video and explore more ways to use IPFS to do p2p video :)

@daviddias
Copy link
Member

For development, check the latest here -- #128 (comment). Closing this issue to avoid duplicated discussion in multiple points.

@ghost ghost removed the status/ready Ready to be worked label Feb 21, 2018
MicrowaveDev pushed a commit to galtproject/js-ipfs that referenced this issue May 22, 2020
Passing HTTPS multiaddr as a string to constructor did not work,
protocol was ignored and unencrypted HTTP was used.

This commit improves parsing of multiaddr constructor parameter
and adds tests to ensure HTTPS is respected in all scenarios.

It also updates iso-stream-http to v0.1.2
which includes fix for "https does not exist"

License: MIT
Signed-off-by: Marcin Rataj <lidel@lidel.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/support A question or request for support P1 High: Likely tackled by core team if no one steps up
Projects
None yet
Development

No branches or pull requests

5 participants