dturing / node-gstreamer-superficial

Superficial gstreamer binding
MIT License
127 stars 45 forks source link

AppSink hangs and blocks the requests (gstreamer-superficial) #29

Closed deepaganesh10 closed 4 years ago

deepaganesh10 commented 5 years ago

Hi all,

I am using gstreamer-superficial library for live-streaming. My NodeJs server starts a websocket server which receives requests from multiple websocket clients. Each websocket client request is per camera. Based on some validations, I start the pipeline on first "start" request and use the same pipeline for different websocket client "start" requests on same camera and I will call pipeline.stop() on last "stop" request. Everything is working fine.

But I see some problems here:

  1. I am printing appsink element on every request and seeing parent property which increases pipeline number (example: parent: '(GstPipeline) pipeline4') on every request. After stopping the pipeline (pipeline.stop()), what happens to that pipeline?

is it actually unreferred? If yes, why the pipeline count is keep on increasing? If I restart my node server, again the count starts from 0

GstAppSink { name: 'sink', parent: '(GstPipeline) pipeline4', sync: true, 'max-lateness': '-1', qos: false, async: true, 'ts-offset': '0', 'enable-last-sample': true, 'last-sample': { buf: null, caps: {} }, blocksize: 4096, 'render-delay': '0', 'throttle-time': '0', 'max-bitrate': '0', caps: 'NULL', eos: false, 'emit-signals': false, 'max-buffers': 1, drop: true, 'wait-on-eos': true, pull: [Function: pull] }

Note: On pipeline.stop(), only gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL); is called. Should we also consider calling something like _gst_elementunref() ? just a thought !!

  1. This is my pipeline : pipeline = new gstreamer.Pipeline(rtmpsrc location=rtmp://localhost:3030/show/111! decodebin ! jpegenc quality=30 ! appsink max-buffers=1 drop=TRUE name=sink);

After watching live-stream for sometime, my node websocket server hangs up. And all the requests which are coming to my websocket server are blocked, none of them proceeds to execute. I have to restart my node server in order to proceed. Since we are using many cameras for surveillance, this becomes blocker. Please help me to solve this

  1. On invoking pipeline.stop() method, I am seeing pipeline new state changed to GST_STATE_PAUSED. it should be GST_STATE_NULL, right? Could you please test once and confirm this.

I apologize for too many questions. Since this has become the blocker, any help would be grateful.

dturing commented 4 years ago

for 1), no, stop() should not unref the pipeline. only when the object is garbage collected, the pipeline should be unref'd. The automatic naming might still increase, i dont know. for 2), it seems impossible to identify the problem from your description. can you produce a minimal test case that shows your issue? Try introduction a queue element before the appsink. Watch memory usage. for 3), Pipeline.stop indeed just calls gst_element_set_state(GST_ELEMENT(pipeline), GST_STATE_NULL);, but the pipeline ending up in PAUSED might be the correct behaviour still... gstreamer ;)

dturing commented 4 years ago

closing (no response)