Home How do I live stream game content to a website using Node and Java?
Reply: 1

How do I live stream game content to a website using Node and Java?

Jeff smith
1#
Jeff smith Published in 2017-12-07 21:24:29Z

I am currently using Socket.io to sort of "stream" video from a Java game application to a ReactJS website. It's pretty slow, and a little janky, but it works.

The programs work by taking a screenshot of the game with Java, compressing it to JPEG, then sending the compressed, Base64 string over Socket.io to the server. The server then sends this Base64 string to the web client (ReactJS), which then renders the Base64 string as an image using CSS.

This method works. I can control the framerate (to an extent...it runs my CPU through the roof if I use 60 FPS or higher), and I can definitely control the compression of the JPEG (the quality of the image).

It does have its limitations though, and I'm still convinced there's a better way of going about this. I've looked on google for a way to stream video from one application to another, but I haven't found one.

What is the best approach to streaming a game, in a Java client, to a website, in ReactJS?

SzybkiSasza
2#
SzybkiSasza Reply to 2017-12-08 04:27:34Z

This is not a way to go!

Streaming codecs are much more effective than JPEG screenshots. For example, any movie compression alghorithm adjusts itself based on available bandwidth and does not keep all the frames. In your case you're rendering all the frames for your game, which kills your machine performance (JPEG rendering is much more power-hungry than rendering a proper video).

Another thing - you should just stream the content as it is, by sending stream of data instead of using base-64, providing a constant stream of video footage.

So, final solution would look somewhat like that:

  1. Capture the view, using FFMPEG library
  2. Create stream out of captured footage
  3. Expose stream via socket
  4. Get binary output on the other side of the network
  5. Probably, just use HTML5 player that should support all the popular encoding/streaming formats.

These links may be helpful to start with:

  • https://github.com/yev/java-ffmpeg-pipe
  • https://github.com/vbence/stream-m
  • http://www.xuggle.com/xuggler/
  • http://fmj-sf.net/ffmpeg-java/getting_started.php

And something in this thread: Stream video in Java

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312382 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO