Get webTorrent to play .mp4 file stored in AWS private s3 bucket

478 views Asked by At

I am using reactjs and flask. After getting the torrent of .mp4 file stored in private s3 bucket, I am trying to displayand play it in browser using webtorrent. But the video content is not loading

This is a follow up question to Load and play 1 GB .mp4 in reactjs, stored in private s3 bucket. For now, the s3 bucket is public. Because private file was throwing error.

Code for reference - https://codepen.io/drngke/pen/abNGbEg

const magnet = 'https://datavocal.s3.amazonaws.com/s3outputx.mp4.torrent'

const client = new WebTorrent()

client.add(magnet, (torrent) => {
  console.log(torrent.files)
  
   torrent.files[0].appendTo('body')

});
client.on("error", (err) => console.log(err))
1

There are 1 answers

4
v25 On

I'm not sure if this will work.

From the webtorrent docs:

To make BitTorrent work over WebRTC (which is the only P2P transport that works on the web) we made some protocol changes. Therefore, a browser-based WebTorrent client or "web peer" can only connect to other clients that support WebTorrent/WebRTC.

And further:

To seed files to web peers, use a client that supports WebTorrent, e.g. WebTorrent Desktop, a desktop client with a familiar UI that can connect to web peers, webtorrent-hybrid, a command line program, or Instant.io, a website.

So I'm guessing S3 would have to support WebTorrent/WebRTC which I don't think it will.

enter image description here

If my understanding of the above diagram is correct, you could run a hybrid client in between S3 and your web-peers, however you'd then need to host the hybrid somewhere which kind of makes S3 redundant in that setup.