Run multiple pipelines in parallel

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Run multiple pipelines in parallel

jles
This post was updated on .
Hello,

First of all saying that I'm relatively new with gstreamer, apologise if
this question is too obvious and/or is already answered which in that case
I'd appreciate the link to the answer.

I've got a simple working pipeline using an appsrc element as source which
it's got the next form:

appsrc -> queue -> omxh264enc -> queue -> h264parse -> filesink

The data is pushed into appsrc running a "need-data" callback function and a
Gmain loop, the snippet code:

loop = g_main_loop_new (NULL, FALSE);

/*SETUP PIPELINE*/

g_signal_connect (appsrc, "need-data", G_CALLBACK (cb_need_data),pipeline);

/* play */
gst_element_set_state (pipeline, GST_STATE_PAUSE);
g_main_loop_run (loop);


The pushed frames into appsrc are coming from a live camera. Now I need to
run multiple pipelines as the described above to be able to record
simultaneously different cameras.

The first thing I thought is to 'copy' the pipeline as a difference
instances  using a structure and run several main loops (g_main_loop_run )
but the gmain loop is blocking so it only be recorded one camera as the rest
won't have the chance to start once the g_main_loop_run is called.

My questions are:

Would it be possible to run multiple pipelines (as described above) in
'parallel'?

What would it be the best way to do this?

Thanks in advance.




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Run multiple pipelines in parallel into same process question

Nicolas Dufresne-5


Le lun. 4 nov. 2019 11 h 55, jles <[hidden email]> a écrit :
Hello,

First of all saying that I'm relatively new with gstreamer, apologise if
this question is too obvious and/or is already answered which in that case
I'd appreciate the link to the answer.

I've got a simple working pipeline using an appsrc element as source which
it's got the next form:

appsrc -> queue -> omxh264enc -> queue -> h264parse -> filesink

The data is pushed into appsrc running a "need-data" callback function and a
Gmain loop, the snippet code:

loop = g_main_loop_new (NULL, FALSE);

/*SETUP PIPELINE*/

g_signal_connect (appsrc, "need-data", G_CALLBACK (cb_need_data),pipeline);

/* play */
gst_element_set_state (pipeline, GST_STATE_PAUSE);
g_main_loop_run (loop);


The pushed frames into appsrc are coming from a live camera. Now I need to
run multiple pipelines as the described above to be able to record
simultaneously different cameras.

The first think I thought is to 'copy' the pipeline in a difference
instances  using a structure and run several main loops (g_main_loop_run )
but the gmain loop is blocking so it only be recorded one camera as the rest
won't have the chance to start once the g_main_loop_run is called.

My questions are:

Would it be possible to run multiple pipelines (as described above) in
'parallel'?

Yes, you can set multiple pipelines into playing state before entering your mainloop. You can also create more later within a main loop message (callback). Note that a mainloop is optional in GStreamer.



What would it be the best way to do this?

Thanks in advance.




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Run multiple pipelines in parallel into same process question

jles
This post was updated on .
Hi Nicolas,
thanks for your answer.

I've got running both cameras what I'm doing is to create two pipelines
copies and the next call back assignment to push data into the correspondent
appsrc:

......

g_signal_connect (appsrc1, "need-data", G_CALLBACK
(cb_need_data),pipeline1);
g_signal_connect (appsrc2, "need-data", G_CALLBACK
(cb_need_data),pipeline2);

......

After configuring and setting both pipelines on playing state I run a
Gmainloop.

I've got the recorded files but the problem is that always the first camera
(pipeline1) works well (smooth playback) and the second camera the video
looks choppy (stops and goes)...


Do I need to create two cb_need_data callback functions for each pipeline (cb_need_data1, cb_need_data 2 ) or can I use the same instance for both?
Any idea what could it be causing this?




--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
gstreamer-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Run multiple pipelines in parallel into same process question

Nicolas Dufresne-5
Le lundi 04 novembre 2019 à 10:37 -0600, jles a écrit :

> Hi Nicolas,
> thanks for your answer.
>
> I've got running both cameras what I'm doing is to create two pipelines
> copies and the next call back assignment to push data into the correspondent
> appsrc:
>
> ......
>
> g_signal_connect (appsrc1, "need-data", G_CALLBACK
> (cb_need_data),pipeline1);
> g_signal_connect (appsrc2, "need-data", G_CALLBACK
> (cb_need_data),pipeline2);
>
> ......
>
> After configuring and setting both pipelines on playing state I run a
> Gmainloop.
>
> I've got the recorded files but the problem is that always the first camera
> (pipeline1) works well (smooth playback) and the second camera the video
> looks choppy (stops and goes)...
>
> Are the pipelines theoretically running in parallel? Could it be a a
> pipeline priority issue?
> Any idea what could it be causing this?
They run on their own thread. It's more likely to small processing-
deadline value (on sinks) or bad timestamps.

>
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Run multiple pipelines in parallel into same process question

jles
Thanks for the clue, yes it was timing related issue.
The problem was actually caused because the time stamp variables were
statically declared in the callback function so both threads where sharing
same variables causing the playback issues.Declaring them as global solved
the problem.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel