streamaserver / streama

Self hosted streaming media server. https://docs.streama-project.com/
MIT License
9.65k stars 986 forks source link

Port to NodeJS? #20

Open dularion opened 9 years ago

dularion commented 9 years ago

Is there general interest for something like this?

z3ntu commented 9 years ago

First: it is funny because your project is running with Java and you consider porting it to nodejs, and then there is "Ogar" an agar.io server implementation. It is currently running in nodejs but v2 will be in Java^^

But for this I actually think nodejs could be nice... I really don't know how performance is with the two platforms but yeah ^^

TL;DR: yes

tegon commented 9 years ago

I agree! It would be great! BTW, if you need some help, i can start doing it here :)

dantheman213 commented 9 years ago

I think NodeJS would be great because you can combine other technologies like ExpressJS/Jade along with back end techs like Socket IO and FFMPEG to get a robust media solution that can stream over the network. For the front end I think AngularJS is a great idea but if you're sufficiently skilled with jQuery you can get away with that + plugins for the front end UI.

phi0x commented 9 years ago

I agree nodeJS is the way to go, reactJS is also something that should be highly considered for frontend/backend, it's used by Netflix and Facebook after-all.

korrio commented 9 years ago

+1 to @dantheman213

dularion commented 9 years ago

I've only ever coded nodejs vanilla style. But I find that sort of tedious. Does anyone know a good MVC that would be suitable for a REST-application?

dularion commented 9 years ago

Also, do you guys use passport or is there a better authentication module out there for node?

dularion commented 9 years ago

@tegon I could always use the help :) For instance, it would be helpful if you could get a basic REST application running with a nice MVC and authentication in place. That already takes care of a big chunk.

dantheman213 commented 9 years ago

@dularion I have a lot of experience with NodeJS. I would recommend using Express as the server MVC framework. Learn more about Express here: http://expressjs.com/

I have created a NodeJS server starting point some time ago. Please check out my repo: https://github.com/dantheman213/nodejs-express-mvc-boilerplate-template

The project above is more of a starting point for a website but can be easily used as a REST server. Reading the documentation will help you get started.

As for authentication, PassportJS works great. You can find an example of local authentication here: http://passportjs.org/docs/authenticate

I've also implemented a custom authentication login system with one of my web apps --it's not too difficult to accomplish!

@Copytalky I'm sure ReactJS has its merits. I haven't used it before but I've had huge success with jQuery and AngularJS (before that backbone) with my web apps. But there are many good tools to get the job done!

dularion commented 9 years ago

I'm pro angularjs also, especially since v2 promises to deliver some really great improvements regarding performance.

@dantheman213 I know Express and I really like it. Didn't know there was an MVC implementation of this, though. I thought of express more as a "deliverer of content for nodejs". But in the case of this app, I am not so interested in the "View"-part of MVC, but rather the Model and Controller part. In the past I always used to structure the apps MVC style with my best judgement, but I would really like some style guide. Your boilerplate does not really touch the subject of Models it seems like.

dantheman213 commented 9 years ago

@dularion Express contains all the elements for an MVC app by default. You have your init code, routes that match URLs to controllers, and then you have your models that will contain your data, and lastly Express comes with Jade by default to manage the views. All of this together provides the MVC framework for rapid application development of web apps and websites.

You don't need to use the 'View' aspect of Express though. When you init an action on a controller you can just do something like this:

router.get('/userlist', function(req, res) {
    // server requested https://api.mysite.com/userlist
    var users = [{UserId: 0, UserName: "timmy"}]; // use logic here to get your data to send
    res.json(users);
});

module.exports = router;

And that's all there is to it, really.

tegon commented 9 years ago

@dularion You can see a comparison here, about popular node frameworks. Sails is the most Rails-like framework, Express can fit all the needs but requires more boilerplate and other libraries, like sequelize, for example. And sure I can create a REST api, I'll be glad to help!

dantheman213 commented 9 years ago

@tegon I like how Express segments everything out. You just install middleware packages for stuff like HTTP auth, rewrite rules, or SSL, for example. But the benefit here is that you're not installing some huge monster web server.. you're just installing what you need for your project and you'll get a performance gain there.

dularion commented 9 years ago

I also saw this: http://www.slant.co/topics/389/compare/~express-js_vs_sails-js_vs_meteor

I think looking at the automatic JSON API, that sails.js may be interesting. what do you think?

dularion commented 9 years ago

And the part about Waterline ORM is really interesting, too

tegon commented 9 years ago

Definitely worth looking, I'll start digging into it

dularion commented 9 years ago

You want reactjs and ionic? ionic uses angular.. isnt that overkill?

dularion commented 9 years ago

Meteor.js seems very interesting though, will take a look at it

dantheman213 commented 9 years ago

Also Ionic is exclusively for mobile apps. It's wrapped with Apache Cordova so that you can cross deploy against mobile platforms.

dularion commented 9 years ago

well, ionic made some very slick and great angular directives which also work on non-mobile. and the cordova is not a must, it is actually a separate library (cordova.js and ngCordova.js). But I agree that it doesnt quite seem to fit here. Especially since I already created an angular frontend, so no need to swap that out with another angular frontend imho. Switching to an entirely different frontend framework is a different story.

stramel commented 9 years ago

I would definitely be in favor of switching to using a Node backend instead of Grails. I actually saw this repo today and was like I should fork and port to Node. So that would save me a lot of time. I do like Express but there are some other alternatives out there as well, Vanilla NodeJs, Restify, Hapi.

For frontend, I would vote staying with Angular and css framework of your choice (assuming bootstrap since that is what is included currently). I agree using Cordova would be a great choice once the app is more stable unless someone wants to issue PRs for it.

phi0x commented 9 years ago

I agree angularJS is great in many ways. I've had various discussions on IRC regarding scalability and performance with JS/PHP programmers and even some facebook members from the reactJS channel. At the end of the day for scalability and performance for our large project we've decided to go with reactJS/nodeJS/immutibleJS (https://facebook.github.io/immutable-js/). Not to say AngularJS can't scale per say, but from the discussions I've seen and the case studies I've read previously, I found react and node are extremely powerful and easy to scale with. Streama from what I see wont be something that need's to really 'scale' large, at least for its intended purpose so honestly anything people are comfortable programming with/in is fine for this project I would think. I just thought I'd mention the frameworks/libraries/environments that I've been seeing getting a lot of attention lately with the larger scale company's/projects and that I've chosen for mine.

At the end of the day, the project should use what everyone feels comfortable using - as long as it gets the end result done.

Only other recommendation I have is do some resource tests for frontend, see how much load a browser utilizes and if it's resource hungry, try to find out what aspect of the project is causing it. Users that have laptops or mobile devices need streams that are as resource friendly as possible, if a browser is using 10-30% of the CPU to stream a show that's going to really put a damper on the usability factor. Servers tend to usually get the spotlight when it comes to resource tests, but thought I'd throw in that other factor for frontend tests seeing as this platform really is both frontend and backend based.

Everyone's suggestion for Cordova seems really great too once the project is more stable like @stramel said.

dantheman213 commented 9 years ago

This may sound crazy but I think that if you want to make a great alternative to options like Netflix or do-it-yourself paid services like Plex that you should create the front-end app using a gaming engine like Unity3D in order to write one code base but be able to deploy to everything!

https://unity3d.com/

Unity3D is free for open source projects and commercial products that generate revenue up to $100,000 annual gross income. It is a full fledged game studio that includes MonoDevelop for cross platform C# ( http://www.monodevelop.com/ ) and deploys to a plethora of platforms such as: Android, iOS, Windows Phone, Blackberry, OSX, Linux, Windows XP+, HTML5 browsers, Xbox 360, Xbox One, PS3, PS4, PS Vita, Wii U and more.

With that type of deployment, I would use Unity as the client application and bite the bullet on the learning curve of Unity and figure out how to use its 2D engine. From there you can then generate interfaces, menus, stream video --everything could occur from within Unity.

On the server end, use NodeJS, Express (or another MVC style framework for REST implementation) Socket IO, and FFMPEG (video conversion, downgrading for lower bandwidth devices, etc).

This would allow for a robust solution and for nearly the same amount of development time, be able to deploy your video streaming application on every platform under the sun and reap the benefits of a network based server --especially if it could serve media securely over the Internet.

dularion commented 9 years ago

Actually I have quite a lot of experience working with unity and its 2d engine, and I agree with you in regards to the different platforms. But: creating interfaces in unity is a PAIN in the ass. also, working with http in it is no picnic either. There seems to be something like webview in unity, but that is not cross platform it seems, and I've never used it, so I don't know if it compares to the mobile webviews out there.

I like your approach, and we should talk more about cross-platforming, but I for one will throw in the towel when it has to be unity, as it is so horrible to work with in some regards (from my experience). BUT: if more of you are interested in this, have at it! I would try to help as much as I can :)

dantheman213 commented 9 years ago

I definitely agree that it would be more difficult. And I have some experience with Unity as well and I know it's no picnic. But if I was to tackle a problem like this I also think the benefit of deploying to everything is appealing to me.

I did find some good tutorials on generating interfaces within Unity. And with release 5 it may have become easier to do so!

https://unity3d.com/learn/tutorials/topics/user-interface-ui

There are videos where a guy is literally walking you through creating a menu.

However, doesn't have to be Unity --just a thought!

yusijs commented 9 years ago

Yes please to node :+1: Java is so horrible on resources it makes me cringe (uploading a video made java use 107% of my cpu (debian is so weird with cpu calculations.. 100% = 1 core) and 25% of my memory)

admwx7 commented 9 years ago

Angular would be significantly faster for rapid development, especially since we have so many developers with experience in it floating around the discussions. Secondly, why reinvent the wheel here? Provide DLNA support and you cover virtually all of your bases for devices that could run unity but not a browser. Cordova would add support for "native" apps on a lot of those devices. More importantly you're not requiring a completely different language in your stack, or a install on every device.

On Tue, Aug 4, 2015, 10:27 AM yusiswtor notifications@github.com wrote:

Yes please to node [image: :+1:] Java is so horrible on resources it makes me cringe (uploading a video made java use 107% of my cpu (debian is so weird with cpu calculations.. 100% = 1 core) and 25% of my memory)

— Reply to this email directly or view it on GitHub https://github.com/dularion/streama/issues/20#issuecomment-127648787.

dantheman213 commented 9 years ago

@admwx7 The idea would be to take the steeper learning curve but have the great ability to write code once and maintain one strict code base. Your idea suggests using alternative protocols and wrappers to target multiple platforms which takes extra work and will also deliver a poorer result. (e.g. cordova apps run like garbage on our older Android devices).

Also, DLNA is almost like a file server view. I don't want to browser folders of my media.. I could just setup a file share from the get go using NFS or SMB or something to do that. I want a pretty interface and logic which DLNA can't provide.

I get that the logical idea here is to create an HTML5 app because of its RAD + multiple platforms qualities. But I think my idea has merit because it targets way more platforms and you're writing your code only once with no wrappers.

For example, I have a PlayStation 4 and I mainly use it as a dummy box to stream Netflix or Plex content. Many people use consoles to stream content so I think that part of having an appealing product is being able to target all these platforms. Netflix and Plex though have tons of resources and can create many version of their product for individual platforms. But as indie/open source developers we don't have that same luxury.

admwx7 commented 9 years ago

DLNA allows push to play services as well, check out emby for example. As for centralized code base, on top of html5 running on literally every platform https://www.raspberrypi.org/blog/web-browser-released/ via web views, Cordova allows for native apps if you chose, now if your site isn't responsive, yeah it's going to look bad on mobile, but if your unity app isn't responsive it would look just as terrible. The difference is your api and frontend logic would all share the same language supported by a larger community that knows that language.

On Tue, Aug 4, 2015, 12:27 PM Daniel Gillespie notifications@github.com wrote:

@admwx7 https://github.com/admwx7 The idea would be to take the steeper learning curve but have the great ability to write code once and maintain one strict code abse. Your idea suggests using alternative protocols and wrappers to target multiple platforms which takes extra work and will also deliver a poorer result. (e.g. cordova apps run like garbage on our older Android devices).

Also, DLNA is almost like a file server view. I don't want to browser folders of my media.. I could just setup a file share from the get go using NFS or SMB or something to do that. I want a pretty interface and logic which DLNA can't provide.

I get that the logical idea here is to create an HTML5 app because of its RAD + multiple platforms qualities. But I think my idea has merit because it targets way more platforms and you're writing your code only once with no wrappers.

For example, I have a PlayStation 4 and I mainly use it as a dummy box to stream Netflix or Plex content. Many people use consoles to stream content so I think that part of having an appealing product is being able to target all these platforms. Netflix and Plex though have tons of resources and can create many version of their product for individual platforms.

— Reply to this email directly or view it on GitHub https://github.com/dularion/streama/issues/20#issuecomment-127685054.

phi0x commented 9 years ago

Webkit was ripped apart by Netflix and converted to 'project gibbon' utilizing react as well for their cross platform compatibility. I'm not familiar with the difference between webkit/cordova but it seems webkit can be utilized across many platforms(PC, Mobile, consoles). Unity sounds like a cool idea but I agree that there's less coders out there that understand it and are willing to go the extra length to get into it.

dantheman213 commented 9 years ago

@admwx7 as far as I've seen DLNA is only a way for devices to see each other over the network and stream media to each other. There's not much more complexity than that. Embry offers a complex user interface for its standard app. Just because your device supports DLNA doesn't mean that's how it'll look on a device you're connecting to the server using that technology. I've attached what it looks like to connect to a DLNA server from a PS3.

ps3-media-stream-windows-1-1

Also, Apache Cordova builds native apps by wrapping a web view on the device and providing a layer to communicate to the OS APIs via Javascript. I've used it in conjunction with the Ionic library. Worked great but had big performance issues on non flagship devices that were even a year or two old.

@Copytalky as this is a open source project and not a huge development team working for a multi million dollar company I think that it makes sense to use this tech or a similar tech in order to be able to accomplish much more then you're able to using convential means.

I get that there is a big learning curve on the project but as a developer that should excite you! More fancy knowledge to slap on the CV. Personally, I get bored doing the same stuff all the time! Web apps were so 2010 lol.

Actually, I get why everyone wants to do a web app. I just feel like if you really want to compete with the other devices out there you gotta target consoles and other platforms too. And using a game engine may be a huge shortcut rather than developing a core and tons of wrappers or different versions of the same project.

admwx7 commented 9 years ago

Download emby, connect to DLNA, then play around in emby's web view, there's a setting to enable "casting" to DLNA devices, so DLNA must support that as part of the protocol, and it works. I can use their mobile app to cast videos to my xbone over DLNA.

I've never run into performance issues on the Cordova based "native" apps I've used, and if you did, open it in a web browser... Without having to install, even a little.

On Tue, Aug 4, 2015, 5:24 PM Daniel Gillespie notifications@github.com wrote:

@admwx7 https://github.com/admwx7 as far as I've seen DLNA is only a way for devices to see each other over the network and stream media to each other. There's not much more complexity than that. Embry offers a complex user interface for its standard app. Just because your device supports DLNA doesn't mean that's how it'll look on a device you're connecting to the server using that technology. I've attached what it looks like to connect to a DLNA server from a PS3.

[image: ps3-media-stream-windows-1-1] https://cloud.githubusercontent.com/assets/10934533/9074128/b2ae652a-3abb-11e5-8e6f-308f27d7d11e.jpg

Also, Apache Cordova builds native apps by wrapping a web view on the device and providing a layer to communicate to the OS APIs via Javascript. I've used it in conjunction with the Ionic library. Worked great but had big performance issues on non flagship devices that were even a year or two old.

@Copytalky https://github.com/Copytalky as this is a open source project and not a huge development team working for a multi million dollar company I think that it makes sense to use this tech or a similar tech in order to be able to accomplish much more then you're able to using convential means.

I get that there is a big learning curve on the project but as a developer that should excite you! More fancy knowledge to slap on the CV. Personally, I get bored doing the same stuff all the time! Web apps were so 2010 lol.

Actually, I get why everyone wants to do a web app. I just feel like if you really want to compete with the other devices out there you gotta target consoles and other platforms too. And using a game engine may be a huge shortcut rather than developing a core and tons of wrappers or different versions of the same project.

— Reply to this email directly or view it on GitHub https://github.com/dularion/streama/issues/20#issuecomment-127779035.

dantheman213 commented 9 years ago

@admwx7 Enable casting? What does that mean? Can you send a screenshot of this working? When I google "DLNA specs" or "DLNA capabilities" I don't see any such thing. In addition, when I look at screenshots of various DLNA servers being run on the client devices it looks like a file server.

I'm pretty sure that's because the embedded DLNA clients in devices like the PS3, PS4, or Xbox are not capable of such a thing. My point here is that while DLNA is good for discovery and streaming (limited formats) it's not going to provide a robust client interface on something like a PS3. The truth is that you need a complex app and a more complex protocol than DLNA to provide a rich experience to your end user.

PS. I have had a ton of experience with DLNA on both the PS3 and PS4. It was just awful. Because it's treated like a file share if you have a large TV Shows or Movies folder good luck navigating through it! Also, no meta data like picture, rating, show name, director, year released, actors, etc. Not to mention trying to seek through a video or wait for the server to be queried again when navigating into a sub folder. I ended up giving it up for self hosted Plex server.

admwx7 commented 9 years ago

Unfortunately I can't link you to the actual specifications because they have them behind a "members" section on their site, but https://en.wikipedia.org/wiki/Digital_Living_Network_Alliance is what I hope to be a solid representation of it. You'll find a section labeled "Home Network Devices" in which it defines Digital Media Renderer (DMR) which is your typical TV or console, and a Digital Media Controller (DMC), which would be streama here. You navigate around in the pretty UI on your phone, or computer, select the TV show you wish to watch, select your DMR device, then press "cast", suddenly your console is playing the TV show you had selected.

When it comes to selecting a tool for representing my media library, a mobile "remote" is my number 1 priority, followed by chromecast and DLNA support. I will never use a native app on my xbone since I wouldn't want to install it to begin with, and I wouldn't want to waste all the time messing with my controller when my phone is so much more convenient.

When I say mobile remote I don't always mean a native mobile app since 2 clicks into a responsive web UI is almost as easy as 1 click into a mobile app.

dantheman213 commented 9 years ago

Hmm, well I'm not convinced DLNA is capable of any such thing. It sounds like what you're doing is using an app that has its own separate database, protocol, etc is doing all the work and then initiating a DLNA stream on the target device with the media you want at the end... which isn't really what I thought we were discussing.

Anyhow, an average user may choose to use their TV OS (Vizio, Samsung, or Android TV), console (Playstation/Xbox/Wii), or a web browser view, or their mobile or tablet device.

The point here is that in order to make an appealing product it makes sense to write the code once and deploy it to everything. You give no excuse to anyone not to use it because it is just so awesome! However, your suggestion is more to program for what you want specifically and I think that if you're going to create a project for people --you should do it right!

I was just looking at Unity tutorials and they have amazing documentation and YouTube videos of people building projects from the ground up. The 2D documentation has everything needed. If you're familiar with C# and/or .NET programming than I think using Unity should be pretty straight forward since it uses C# and MonoDevelop (instead of .NET) to compile the code.

I think there is definitely a learning curve to learning how the engine works and then make it behave in a non-standard way but if you're able to implement interfaces, perfect video streaming, and networking than why not take advantage? I mean games have to do all that stuff anyways, right?

admwx7 commented 9 years ago

I literally linked you to a condensed version of the DLNA spec, and that's what I've been referring to all along, hence why I mentioned playing around with Emby and it's settings...but I created #64 to discuss this since we're flooding an unrelated ticket.

If you can think of anything in favor of one or the other then go for it, I can't at this point and need to get back to work anyway. I do have to say, you'll probably lose a decent portion of followers by switching away from a JS front-end, that's one of the things that caught my interest TBH.

P.S. I'd also like to point out that Plex has a native app for playstation 3/4 - https://plex.tv/playstation

dantheman213 commented 9 years ago

@admwx7 you linked me to the Wikipedia page and it doesn't prove your point in any way.

Also, I know Plex has a Playstation app. I use it all the time :)

dantheman213 commented 9 years ago

For anyone interested, I ended up creating a repository to experiment with the idea of using Unity as the client. You can find it here:

https://github.com/dantheman213/ambrosia

If I have enough time it's something that I'm interested enough in to pursuing. Hopefully I can get enough of the project done to get some other devs interested!

stramel commented 9 years ago

This article talks about how Netflix is using NodeJS, ReactJS to create a faster UI. http://techblog.netflix.com/2015/08/making-netflixcom-faster.html?utm_source=SitePoint&utm_medium=email&utm_campaign=Versioning

dularion commented 9 years ago

FYI, I am currently working on a port to NodeJS with sails.js

yusijs commented 9 years ago

Have you added this to a branch yet?

dularion commented 9 years ago

Nope, will do it soon. still getting the basics going, reading a lot of documentation atm :)

admwx7 commented 9 years ago

:+1:

On Fri, Aug 7, 2015 at 12:51 PM Antonia Hulha notifications@github.com wrote:

Nope, will do it soon. still getting the basics going, reading a lot of documentation atm :)

— Reply to this email directly or view it on GitHub https://github.com/dularion/streama/issues/20#issuecomment-128777216.

yusijs commented 9 years ago

Fair enough - looking forward to it!

tegon commented 9 years ago

@dularion I did some basic CRUD and initialized authentication in my fork, do you want to create a branch here, so we can see what we can merge?

dularion commented 9 years ago

Did you work in sails or another framework?

tegon commented 9 years ago

In Sails

dularion commented 9 years ago

ah cool! I am still working on getting mine off the ground with the basic models needed in streama, so I will add a branch soon

yusijs commented 9 years ago

Any progress!:)

dularion commented 9 years ago

Yea sorry! It's actually kind of difficult to try to maintain this version for the users who use it and also work on a completely different setup at the same time :P But I will try to make time asap