DevL0rd / SkyNX

Stream your PC games to your Nintendo Switch without Android!
GNU General Public License v3.0
610 stars 44 forks source link

Linux version? #42

Open ghost opened 4 years ago

ghost commented 4 years ago

Personally i don't play at all in Windows, I only use Manjaro to game. Is there a plan for releasing a Linux version w/ all the features? I can test it if needed! Thanks.

MrSnoozles commented 4 years ago

Check #1. It is planned but currently not in the works as far as I know.

ghost commented 4 years ago

I saw it, but as they talked mostly about a mac port i decided to open this issue. I don't see much problem emulating the controllers on linux as pretty much all controllers have kernel support or open source "drivers".

thomascrha commented 4 years ago

Its an electron app so building it on Linux shouldn't be to hard - it actually working properly is another issue. I'm going to give this a go - npm i && npm run start and see what road blocks pop up

y4my4my4m commented 4 years ago

Only seem to work with nodev8 and also this is the result: image

Obviously it's trying to launch an .exe on linux which is why its not working lol

y4my4my4m commented 4 years ago

Ok, I kind of got it to work after hacking away a bunch of the code.

Basically, you need to build the NxStreamingService using Nexe (like the build.bat but change to linux-x86). Change all references of NxStreamingServices.exe to without the .exe.

Also comment out any reference to Vgen and vgen (xbox controller because windows only and uses DLL). As well as change ffmpeg.exe to your install of ffmpeg on linux ( /usr/bin/ffmpeg in my case)

Now I can connect and it doesn't crash, the touch controls work well, however the video streaming doesn't actually work. I'll keep investigating.

mirh commented 4 years ago

I think this is the trick https://trac.ffmpeg.org/wiki/Capture/Desktop

y4my4my4m commented 4 years ago

@mirh yes..ive been trying to get the right ffmpeg output, x11grab seems to be the best solution but i still can't get to stream over TCP...probably just bad configuration.

My current arguments are

ffmpegVideoArgs = ["-probesize", "50M", "-hwaccel", "auto", "-f", "x11grab", "-framerate", fps, "-video_size", screenWidth + "x" + screenHeight, "-draw_mouse", "1", "-i", ":0.0+0,0", "-f", "h264", "-vf", "scale=1280x720", "-preset", "ultrafast", "-tune", "zerolatency", "-pix_fmt", "yuv420p", "-profile:v", "baseline", "-x264-params", "nal-hrd=cbr", "-b:v", quality + "M", "-minrate", quality - 3 + "M", "-maxrate", quality + "M", "-bufsize", (quality / 2) + "M", "tcp://" + ip + ":2222"];

But I'm getting this error:

Output #0, h264, to 'tcp://192.168.0.249:2222':
  Metadata:
    encoder         : Lavf58.29.100

    Stream #0:0: Video: h264 (libx264), yuv420p, 1280x720, q=-1--1, 5000 kb/s, 120 fps, 120 tbn, 120 tbc
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 5000000/0/5000000 buffer size: 2500000 vbv_delay: -1

av_interleaved_write_frame(): Connection reset by peer
Error writing trailer of tcp://192.168.0.249:2222: Connection reset by peer

frame=    1 fps=0.0 q=42.0 Lsize=      50kB time=00:00:00.00 bitrate=49290.3kbits/s speed=0.283x    
video:50kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.000000%

[libx264 @ 0x5653513a0b80] frame I:1     Avg QP:42.00  size: 51342
[libx264 @ 0x5653513a0b80] mb I  I16..4: 100.0%  0.0%  0.0%

[libx264 @ 0x5653513a0b80] coded y,uvDC,uvAC intra: 44.6% 19.5% 17.6%
[libx264 @ 0x5653513a0b80] i16 v,h,dc,p: 34% 43% 20%  3%
[libx264 @ 0x5653513a0b80] i8c dc,h,v,p: 80% 17%  3%  0%
[libx264 @ 0x5653513a0b80] kb/s:49288.32

Conversion failed!

VideoProcess process exited with code 1

If someone knows how to fix this, let me know.

y4my4my4m commented 4 years ago

I got it to work!!!

Enabling debug in settings.json made it work.. Unsure why, but it works :)

@DevL0rd let me know if you'd like to make a linux version would like assistance.

khalilgharbaoui commented 4 years ago

I think this is the trick https://trac.ffmpeg.org/wiki/Capture/Desktop

Is this something we can use for macOS also? Related to: #1

and @y4my4my4m do you have a fork for your version in its current state? I'd like to see what code you hacked away to get this working and maybe piggyback off that to create a macOS build?

y4my4my4m commented 4 years ago

@khalilgharbaoui

Here it is:

https://github.com/y4my4my4m/SkyNX/commit/43bed97d65bdc223139ac0fdca34cf26e21c1784 Don't forget to change the SkyNX-Streamer/settings.json to debug:true as well.

Is this something we can use for macOS also?

You can't use "Desktop" as it is for DirectShow (a Microsoft Windows thing).

For Linux I'm using x11grab, I'm not sure if macOS still uses X but it's probably something different nowadays, look for ffmpeg's screencapture parameters for macOS.

I'm quite sure my changes would work for macOS as well (although change linux-86 to something macos (darwin?) appropriate (look up nexe's parameters for macOS so you can build NxStreamingService)).

You should change NxStreamingService to NxStreamingService.app or something like that as well, it depends on how nexe builds it's apps.

Obviously the xbox controller doesn't work. I was only interested in SkyNX as a way to use my Switch as a secondary monitor :)

Zedjones commented 4 years ago

Does it work with using the Joycons as a controller? @y4my4my4m

y4my4my4m commented 4 years ago

@Zedjones probably not, it uses the "xbox controller" on windows to detect input. But I haven't tried...lol

Probably doable by using this https://github.com/infusion/node-gamecontroller instead though. Looking at SkyNX source code (the app running on the switch) there dsnt seem to be anything xbox specific code, so this must all be done on the NxStreamingService side.

https://github.com/DevL0rd/SkyNX/blob/ff471143d545224a178cab63bab9a34411f2bcf6/SkyNX-Streamer/NxStreamingService/main.js#L9

This module should/could be replaced with node-gamecontroller (or something better)

winghugs commented 4 years ago

@y4my4my4m

I'm using your fork version including the debug thing. I've gotten it built for Linux but I'm getting a missing file. When I run npm install again in resources/app I get a version mismatch error, but when I go to install the proper version, I get missing file error again. Any ideas? What steps did you take to get this working, starting from scratch with your modified source.

y4my4my4m commented 4 years ago

@soripants What version of Node are you using? Seems to only compile if you're using node v8.

Have you renamed all .exe references for NxStreamingService (to without the .exe)? (Should be if youre using my fork) You need to rebuild it using Nexe

Is your ffmpeg installed at "/usr/bin/ffmpeg" ? If not might need to change it (although this shouldn't have anything to do with the version mismatch error).

robrichardson13 commented 2 years ago

Spent a little time and I was able to get this working on Mac (Monterey 12.5.1).

https://github.com/robrichardson13/SkyNX

Install ffmpeg via brew with brew install ffmpeg, then using node v12.15.0 just run npm install in the SkyNX-Streamer directory and then npm start to run the application.

If the capture device is wrong for ffmpeg, run this to get the correct device index: ffmpeg -f avfoundation -list_devices true -i "". Depending on the index, you might need to update const screenDeviceIndex = '1'; in main.js.

Notable changes:

knives-repo commented 1 year ago

Spent a little time and I was able to get this working on Mac (Monterey 12.5.1).

https://github.com/robrichardson13/SkyNX

Install ffmpeg via brew with brew install ffmpeg, then using node v12.15.0 just run npm install in the SkyNX-Streamer directory and then npm start to run the application.

If the capture device is wrong for ffmpeg, run this to get the correct device index: ffmpeg -f avfoundation -list_devices true -i "". Depending on the index, you might need to update const screenDeviceIndex = '1'; in main.js.

Notable changes:

* Commented out the Xbox controller implementation using the `vgen-xbox` package

* Commented out audio streaming

* Commented out the auto start functionality as that was crashing the app

* Added WSAD mapping to the joysticks, just comment out the calls to `handleLeftStick()` if you dont want this

@robrichardson13 I'm having trouble compiling with npm 12.15.0. I keep getting errors (electron etc.). Was wondering if you have an exportable build that can be downloaded?

knives-repo commented 1 year ago

Ok, fixed my issues: