Correct EOS when saving stream from USB camera

gotsring gotsring at
Sat Mar 13 15:20:44 UTC 2021

It doesn't look like you're stopping the pipeline correctly, so the data is
never written to the file. In your first attempt, you are waiting for an
EOS, but you never actually send one. In the next, you send an EOS, but then
immediately stop the pipeline, so the EOS never goes anywhere.

To stop a pipeline, you need to
 - Send an EOS event to the pipeline
 - Wait for it to travel through the pipeline
 - Set the pipeline state to READY or NULL
 - Proceed with anything else

Check out this example code. It creates the pipeline, runs it, and then
schedules an EOS event to be sent. When the cb_message function receives the
EOS signal, this means it has reached the end of the pipeline, so it is safe
to stop the pipeline.

It uses gst_parse_launch to create the pipeline, but you can switch to the
manual method as needed.
I used g_timeout_add_seconds() to schedule the EOS, but you can easily
capture ctrl+c signals or other keyboard events to send an EOS.

Sent from:

More information about the gstreamer-devel mailing list