I am trying to build a gstreamer pipeline that takes a video stream from h264 USB camera and does something with it (display it on screen, record it to a file, ect.). If an error occures in pipeline, I would like to print it out and terminate the pipeline. For example: If USB camera gets unplugged, the pipeline should terminate and there should be an error message printed out.
Using the following simple pipeline works as desired:
gst-launch-1.0 v4l2src device=/dev/video2 ! decodebin ! autovideosink
The pipeline displays the video and when I unplug the camera, the pipeline terminates and prints the following output:
v4l2src0:
Error: gst-resource-error-quark: Could not read from resource. (9)
Debug: gstv4l2bufferpool.c(1040): gst_v4l2_buffer_pool_poll (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
poll error 1: Resource temporarily unavailable (11)
When I was building a more complex pipeline (that fits my needs), I found out that the error message was not propagated through the pipeline and thus it did not terminate the pipeline. I narrow it down to the "trouble maker" element and it turns out to be the queue element.
The following pipeline does not work as desired anymore:
gst-launch-1.0 v4l2src device=/dev/video2 ! queue ! decodebin ! autovideosink
When camera is unplugged the video display freezes indefinitely without terminating the pipeline.
Is this a normal behavior? What am I missing? Is there a workaround?
PS.: I tried to simulate an error message with identity element and its error-after property.
gst-launch-1.0 v4l2src device=/dev/video2 ! identity error-after=60 ! queue ! decodebin ! autovideosink
This pipeline also works as desired, meaning it gets terminated with a relevant error message.