Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Live stream to rtmp from backend nodejs

I am using react client and nodejs server. I need to stream from backend to the rtmp url got from live-api from google.
I am sending buffer of webcam from react to nodejs backend. How to send this continous buffer to google? Using socket to send and get buffer.
So, how to stream 

0 1 263
1 REPLY 1

Hi @altRadar-deuglo,

Welcome to Google Cloud Community!

It seems like you're headed in the right direction by transmitting the webcam buffer from React to your Node.js backend. For sending the data to the RTMP URL through Google Live API, you can attempt any of this alternative method:

  1. Use FFmpeg in the backend: FFmpeg is perfect for this scenario. You can pipe the video buffer from Node.js to FFmpeg and have it stream directly to the RTMP URL.
  2. Socket handling: On your Node.js server, make sure you're properly collecting video chunks and passing them to FFmpeg's stdin. This will allow FFmpeg to handle the live stream seamlessly.
  3. fluent-ffmpeg: For an easier implementation, you could try using a library like fluent-ffmpeg to manage FFmpeg within Node.js.
  4. Error handling: Don't forget to manage socket errors to keep the stream uninterrupted. Reconnect the socket if necessary to avoid breaks in the stream.

This might help you get the stream running smoothly to the RTMP endpoint.

I hope the above information is helpful.