How to properly terminate a complex stream with tee and avimux

Tim Müller tim at centricular.com
Tue Aug 12 08:32:36 PDT 2014


On Tue, 2014-08-12 at 08:00 -0700, tnewman wrote:

Hi Tye,

> Thank you very much!  That seems to have worked.  I will continue
> testing, the pipeline does not seem to be extremely stable just yet.
> It seems to work for a few video recordings and then simply hangs.
> Not sure what is hanging.  Also, the start up of the pipeline for the
> first time adding the recording pipeline segment seg-faults from time
> to time.  Any ideas on that?  I suspect that this is the same cause
> for the hanging mentioned earlier.

I did not run your code, only glanced at it briefly.

If you get a crash, a stack trace would be helpful to see where the
problem comes from. Make sure to run it through valgrind as well if you
can.

 Cheers
  -Tim

> 
> On Tue, Aug 12, 2014 at 4:08 AM, Tim Müller [via GStreamer-devel]
> <[hidden email]> wrote:
>         On Mon, 2014-08-11 at 06:25 -0700, tnewman wrote: 
>         
>         Hi, 
>         
>         > I have been attempting to create a complex pipeline with
>         some success except 
>         > for how to close the video saving (avimux) portion of the
>         stream.  Below one 
>         > will find an illustration of the pipeline. 
>         > 
>         > 
>         > 
>         > Here is the story:  I have an embedded device where I need
>         to create a video 
>         > stream to a fakesink; where the fakesink is used to hand
>         framebuffers to a 
>         > Qt application to be displayed in a widget.  This is the
>         primary stream 
>         > connected to the tee as seen above.  The second portion of
>         the stream is the 
>         > connected to the tee on request (a user pushes a Qt button)
>         and begins 
>         > recording an AVI file to disk.  The addition of this
>         pipeline to the tee 
>         > seems to be working (most of the time, sometimes the
>         pipeline hangs; but 
>         > that is for later).  The issue is when the user presses the
>         Qt button again 
>         > to stop the recording.  The first time through it works, the
>         filesink sees a 
>         > EOS event and the file terminates with an updated header.
>          The problem comes 
>         > the second time around.  From the g_print statements one
>         sees this: 
>         > 
>         > 
>         > 
>         > And thereafter the pipeline fails. 
>         > 
>         > Below one will find the source code for the project.  Any
>         help would be 
>         > greatly appreciated. 
>         > 
>         > 
>         > 
>         > I have tried may variants with no success. So the real
>         question is: how does 
>         > one unlink a section of the pipeline from the tee, terminate
>         the avimux and 
>         > audio source elements to create a proper AVI file, remove
>         the elements from 
>         > the pipeline and then at a later time recreate these
>         elements, link them, 
>         > and do it all over again.
>         event_probe_cb() will be called from the streaming thread, the
>         same 
>         thread you want to shut down. This won't really work well like
>         this. 
>         What you should work better is something like this: 
>         
>          - set g_object_set (pipeline, "message-forward", TRUE, NULL) 
>            so you get a message on the bus even if just filesink is
>         EOS 
>            (but not the other sink) 
>         
>          - wait for an GST_MESSAGE_ELEMENT on the bus like this: 
>         
>             case GST_MESSAGE_ELEMENT:{ 
>               const GstStructure *s = gst_message_get_structure
>         (msg); 
>         
>               if (gst_structure_has_name (s, "GstBinForwarded")) { 
>                 GstMessage *forward_msg = NULL; 
>         
>                 gst_structure_get (s, "message", GST_TYPE_MESSAGE,
>         &forward_msg, 
>         NULL); 
>                 if (GST_MESSAGE_TYPE (forward_msg) == GST_MESSAGE_EOS)
>         { 
>                    ... shut down / remove pipeline branch ... 
>                 } 
>               } 
>               break; 
>             } 
>         
>          - This assumes you unlinked the tee branch and sent an EOS 
>            yourself on the queue's sink pad before jpegenc and 
>            to audiotestsrc via gst_element_send_event(). 
>         
>          Cheers 
>           -Tim 
>         
>         -- 
>         Tim Müller, Centricular Ltd - http://www.centricular.com
>         
>         _______________________________________________ 
>         gstreamer-devel mailing list 
>         [hidden email] 
>         http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>         
>         
>         
>         ______________________________________________________________
>         If you reply to this email, your message will be added to the
>         discussion below:
>         http://gstreamer-devel.966125.n4.nabble.com/How-to-properly-terminate-a-complex-stream-with-tee-and-avimux-tp4668269p4668277.html 
>         To unsubscribe from How to properly terminate a complex stream
>         with tee and avimux, click here.
>         NAML 
> 
> 
> 
> 
> ______________________________________________________________________
> View this message in context: Re: How to properly terminate a complex
> stream with tee and avimux
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

-- 
Tim Müller, Centricular Ltd - http://www.centricular.com



More information about the gstreamer-devel mailing list