I didn't know that using one webcam with multiple programs at the same time was a problem.
My program has two components that use v4l2src:
- Preview yourself;
- Sending to
udpsink.
I hoped to achieve this with appsrc/appsink:
Create a common webcam component that inside has a pipeline:
v4l2src ! video/x-raw,width=640,height=480 ! appsink,
and has a methodsetupAppSrcfor other components that need to use it.PreviewSelfhas a pipeline:
appsrc ! videoconvert ! xvimagesink.VideoSenderhas a pipeline:
appsrc ! videoconvert ! x264enc ! h264parse ! rtph264pay ! application/x-rtp, media=video, encoding-name=H264, payload=96 ! udpsink.
appsink has a signal new-sample. Let's connect to it, receive the data using gst_app_sink_pull_sample and send it to the installed GstAppSrc using gst_app_src_push_sample.
Possible create multiple PreviewSelf and they will work well. But as soon as I add a VideoSender, everything freezes.
I tried to do:
gst-launch-1.0 v4l2src ! video/x-raw,width=640,height=480 ! tee name=mux \
mux. ! queue ! videoconvert ! xvimagesink \
mux. ! queue ! videoconvert ! x264enc ! fakesink
And It freezes too.
Tell me, please, how several components can use a webcam?
Your queues are too small for your
teepipeline. Increase them or usetune=zerolatencyfor thex264encelement.