Correctly terminating a recording with multiple sources

Adam Goodwin adam.goodwin.nz at gmail.com
Tue Sep 10 23:55:06 PDT 2013


Hi again,

For my C application, which records multiple camera streams to file (and
kind of records subtitles), I've had plenty of issues with my MKV files
being played in unexpected ways by VLC. But if my pipeline only ever
records one stream to the MKV file, it seems to be perfect every time. If
there is more than one stream going into the matroskamux (irrespective of
it being a video or subtitle stream) this is when I start getting problems
with VLC; such as the progress through the video not being correctly
displayed.

I've now realised that I never made sure I was terminating the recording
properly. I don't think this is the one single cause of all my
application's problems, but I do remember that a guaranteed way to get a
broken MKV file is to not end the stream correctly.

Currently my application terminates upon user request. This is done through
standard input. When the command is entered by the user, my IO callback
recognises it and generates an EOS event as follows:

gst_element_send_event(pipeline, gst_event_new_eos());

Then, as per most of the examples in the manual, I watch the GStreamer bus
for a message of type GST_MESSAGE_EOS. When this message is seen, I
immediately call g_main_loop_quit(loop) and the pipeline is set to
GST_STATE_NULL before being deleted.

I don't know how exactly the sending of the EOS event works, but I
understand that the EOS *message* doesn't appear until all sinks in the
pipeline have received and handled the EOS event.

Out of curiosity I have tried sending an EOS event to every source element,
instead of just sending one to the pipeline as a whole, but this has made
no difference. I have verified though that if I miss a source element out,
then the EOS bus message doesn't arrive and the application doesn't shut
down.

So from this I am led to believe that the matroskamux doesn't emit the EOS
event from its source pad unless it has received one from all of its sink
pads. This would indicate to me that I am doing things correctly, and that
the MKV file should be getting terminated correctly by the muxer, but it
certainly doesn't work out that way.

Long story short, is my current approach correct? And if not, what is the
correct way to shut down my pipeline? (Thanks for reading all of this!)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20130911/f1cd403d/attachment.html>


More information about the gstreamer-devel mailing list