node-webrtc / node-webrtc-examples

MediaStream and RTCDataChannel examples using node-webrtc
514 stars 161 forks source link

Videostream not displaying in chrome #42

Open CodingSaturn opened 3 years ago

CodingSaturn commented 3 years ago

Hey everyone,

for a project my goal was to livestream a video from a pipeline defined using gstreamer to the browser. I don't have prior experience with webrtc but the video-compositing example made me achieve streaming the following video to the browser. I only changed a view lines to make this work.

const gstreamer = require("gstreamer-superficial");
const { RTCVideoSource } = require('wrtc').nonstandard;

let numOfClients = 0
let pipeline = null

function beforeOffer(peerConnection) {
  if (numOfClients == 0) {
    console.log("starting new pipeline");
    pipeline = new gstreamer.Pipeline("videotestsrc is-live=True ! videoconvert ! videoscale ! clockoverlay shaded-background=true ! video/x-raw,format=I420,width=1024,height=576,framerate=25/1 ! appsink name=sink");
  }
  numOfClients++;
  console.log("new peer connected");
  console.log(numOfClients, "Clients connected");
  const appsink = pipeline.findChild('sink');
  const source = new RTCVideoSource();
  const track = source.createTrack();
  peerConnection.addTransceiver(track);

When testing in firefox everything works fine and the videoframes get displayed correctly. However when I visit the same page on chrome it doesn't work and there are no error messages. Therefore I don't know if it is a problem with my addition or something about node-webrtc that isn't working correctly.

The only thing I could think of was printing the MediaStreamObject to the console and it looks the same in firefox and chromium (only values filled there are an 'id' and a boolean named 'active' set to true, 'onaddtrack' and 'onremovetrack' are both null. Chrome also prints two other values which firefox doesn't display which are 'onactive' and 'oninactive' both set to null, which firefox doesn't show)

The version I tested this on were:

I also asked the question on stackoverflow but as I don't get any error messages in the browser my hopes aren't too high that someone knows what the problem is. Anyway you can find it here.

Thanks in advance!

(PS: I saw question #41, which could be the same problem as I am experiencing but I am not sure, so I wanted to open an additional issue)