dturing / node-gstreamer-superficial

Superficial gstreamer binding
MIT License
130 stars 45 forks source link

Getting examples/streaming/server.js to work? #6

Closed gregfutia closed 7 years ago

gregfutia commented 7 years ago

Any ideas on how to get examples/streaming/server.js to work? You acknowledge on the main page that it's broken. I want to try to stream the appsink to multiple clients like you did in this example. I want to do it from MP4 streams or similar to what mpeg-streamer does. I got this example to work but it's seems only compatible with one client.

I got it to run after express-logger is installed npm install express-logger --save . I changed the app.use on line 39 to app.use( logger({path: "logfile.txt"})); just to get it to run.

The main issue seems to be appsink.pull(function (buf) {..} is only being called one time. Shouldn't it be called continuously after the stream is put into play? This is what happens the appsink.js examples.

The second issues is the appsink.pull function(caps) {..} is never called. I like what you were trying to do here so I guess this just means lines 43-45 aren't used.

I uncommitted lines 13 and 23 and get the output below when I run server.js. The only one display of BUFFER size 70 indicates just one invoke of the callback.

I played with adding is-live=true and drop=true to the pipeline. That didn't fix it. I can try other ideas on debugging.

--Server Output-- Running http server on port 8001 bus message: { type: 'state-changed' } BUFFER size 70 bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'stream-status' } bus message: { type: 'state-changed' } bus message: { type: 'stream-status' } bus message: { type: 'stream-start' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'async-done' } bus message: { type: 'new-clock' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' } bus message: { type: 'state-changed' }

dturing commented 7 years ago

sematics of appsink.pull have indeed changed, now you need to call pull for each buffer (before, your callback would be called again and again); but this is not the main problem why the example is dysfunctional.

for streaming, you need to send a codec header for each client upon connection; gst supports this by attaching the "streamheader" to caps. this is how the example handled it earlier.

the caps passing is currently dysfunctional (i think @skyrising might have some improvements though).

I've patched the examples to blindly use the first two buffers received via appsink as streamheader. It works in my test, for an ogg/theora video-only stream, but will likely break when using other codecs.

dturing commented 7 years ago

i've managed to bring back the caps passing; now the sample works as earlier, with proper streamheader handling.