jaruba / PowderNPAPI

(deprecated) Peerflix interface for the browser. (npapi plugin)
GNU Lesser General Public License v2.1
12 stars 0 forks source link

Information about building process and questions #1

Open dedesite opened 8 years ago

dedesite commented 8 years ago

Hi Jaruba,

I was working on a same project when I found PowderNPAPI and even if NPAPI does not have a bright future, i'm interested in going a bit deeper.

Could you give more informations about the building process ?

I'm also thinking about ways to build a plugin compatible with new APIs. I understood that firefox will maybe use NaCl in the future, have you any idea if it's possible to compile a node.js application to NaCl ? A quick search doesn't give anything interesting.

Anyway, thanks for your work :+1:

jaruba commented 8 years ago

Hey @dedesite ,

I'm afraid I can't offer you the information you might need for this, as I'm unfamiliar with NaCl. As for this particular repo, it was a 2 day project I did for fun, more so without any knowledge of C++.

Got it working either way though, I enjoyed playing with C++ a bit, but the way it worked was far from ideal.

How did you embed peerflix into the plugin ?

  • I bundled peerflix and a standalone node.js inside the package (see here)
  • used the NPAPI bridge to fetch the user submitted magnet link
  • interfaced the bundled peerflix through the command line
  • scrapped the output of peerflix periodically
  • sent the scrapped output through the NPAPI bridge back to the browser page
  • on the browser page I parsed the scrapped info with JS to make it an object of readable information
  • played the url that peerflix provided with WebChimera (also an NPAPI plugin)

Does the plugin open .torrent and magnet link ?

Nope, just magnets.

If not, do you think this is possible ?

I'm not sure, I don't think so. The issue I see with it is the uploading of a torrent..

To upload a file, you need a user to select the file in a file input field, but then to get access to that file you need to also have access to the server where it would be uploaded, and I don't think this is doable with just JS as you probably want it to work on any site, not just your site..

Did you try to build the plugin on Linux ?

No I didn't.. but it would definitely require some changes, as I said, I bundle node.js and peerflix inside it, and I only bundled the windows binaries for them. The paths to them might also be hardcoded into the plugin if I remember correctly.

Could you give more informations about the building process ?

Uff, this is such an old project, all I remember is that I used Visual Studio to edit the code then Wix to build the installer for it.

You can find the Wix template to build it for Win here: https://github.com/jaruba/PowderNPAPI/tree/master/src/Win/WiX

I see there are other templates for OSX too in the project (might be for Linux too, I don't know), but again, this is not something I tried and would not work without changing some minor things here and there.

jaruba commented 8 years ago

If you ask me though, you shouldn't go down this road, the reason I say this is because with the deprecation of NPAPI plugins, there is a bigger issue here then just downloading the torrents and that is the requirement of playing the streams in the browser.

As the deprecation of NPAPI means the deprecation of all NPAPI based browser players, there is no longer any way to play whatever type of video you want in the browser.

So your left with just playing mp4 in the browser, but the media in torrents can have any kind of video encoding. So the only possible solution would be to transcode (with ffmpeg) all these types on the fly (while still downloading) to mp4 just to play them in the browser.

This will result in huge CPU usage, as transcoding is a heavy task, and all this just so the video frames will be inside the browser window. My NPAPI solution was the right way to do it, it did not create any significant overhead, but this was in a time when NPAPI players existed.

Torrents should be streamed and played locally, as I do now in another project I built (Powder Player), doing it in the browser these days is just not a feasible solution anymore.

dedesite commented 8 years ago

Thanks for your quick answer.

I understand that it was just a hobby project (like mine) and it's kind of cool for just 2 days !

If I continue the NPAPI approach, I'll definitely use your sources for inspiration. It's a pity there is no way to do the stuff we could do with NPAPI but with newer API, don't why Google, Mozzila and others doesn't want user to play with their browsers...

You're right about the video that won't play if there is not another pluging.

I started to think about doing such plugging when I saw that some people create a "torrent-time" plugin to stream video in the browser and that PirateBay directly integrate it into their website. The problem is that this plugin isn't open source and does not support Linux. Then, I though that we could do more than stream video into the browser, we could integrate torrent seamlessly also for download. For example, you want to download an ISO for a Linux distro, you click on a torrent file, then it opens directly into the browser (like an http or ftp directory) and then you can select which file you want to download. This way, this could leverage server usage.

I'll try to find if there could be another way of doing such a plugin. After all, nodejs is js and browser extension are written in js. Torrent-stream just need to have access to the disk and a way to create sockets, maybe browsers support (or will support) this type of features without using NPAPI ?

Anyway, thanks for your help, I'll have a look at your player which seems to be fine :).

Cheers

jaruba commented 8 years ago

Torrents-Time does it exactly the way I said, it uses ffmpeg to transcode the videos then pushes the transcoded streams to the browser.

But it also uses a local app (that is always active as a service), not just the plugin. It should be easy enough to make a local application based on node.js that communicates with a browser plugin through websockets. Thus the local app downloads and sends back the transcoded streaming URL to play in a <video> tag.

It's not rocket science, I could do all this in 1-2 days, and do it better then they did.. but it's just a really really bad way of doing things, it's like sticking a big rock on a turtle's back just for the fun of seeing it walk harder. Not to mention the many security issues that come with exposing a torrent downloading API to any browser page..

The fact that some large sites accepted this idea like it was some sort of magical solution just proves the low level of developer quality of the people that work on those sites.. Me and many more other devs LOLed when we saw the news story, as we know the sort of shady craftsmanship that was used to make it.

dedesite commented 8 years ago

I never used torrents-time cause I'm on linux. I didn't knew they were doing transcoding, it's such a bad idea, what a waste of resources !!!

I didn't knew also that it require an extern app to run, what a shame. It's really useless ! Popcorn-time was a much more elegant solution IMHO.

For me, bittorrent is a great tech and browser should embrace it, cause it could leverage server usage and also limit centralization (ie youtube). It may be easier to share illegal content with it but when I see the number of illegal streaming websites I'm a bit perplex...

jaruba commented 8 years ago

Well there's webtorrent that's available for a while now, that can handle torrenting in the browser without any plugin, if you keep a mp4 only policy you can literally make a "decentralized youtube" right now if you want, and it will work in all browsers and on all platforms.

But yeah, the way Torrents-Time works is by doing something that no professional developer would ever do as long as he was in his right mind.

dedesite commented 8 years ago

webtorrent is interesting but doesn't communicate with other bittorrent client, you need an hybrid webtorrent/bittorrent client to do the link... Some people are already trying to do a decentralized youtube using IPFS which is a very promising technology but not yet available for the browser. They use WebRTC (like webtorrent) which allows a lot of good stuff like for example get ride of skype.

If this protocol get use at a wider range, it'll be very cool !

jaruba commented 8 years ago

From my knowledge, peerflix and webtorrent share peers since they both use the same peer discovery module now. As for IPFS, I worked a bit on the Alexandria Project which has a local application that communicates with the browser page in order to pass streaming links. I'm planning to add IPFS support in Powder too at one point, although it's at such a low priority that it won't happen anytime soon.