Correctly terminating a recording with multiple sources
Thiago Sousa Santos
thiago.sousa.santos at collabora.com
Wed Sep 11 05:38:09 PDT 2013
On Qua, 2013-09-11 at 18:55 +1200, Adam Goodwin wrote:
> 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!)
It should be the correct approach, yes. Have you checked if the
resulting file could be played with gstreamer itself?
gst-launch-1.0 playbin uri=file:///path/to/file
Or maybe inspecting the file with some mkv parsing tool:
http://www.matroska.org/downloads/mkvalidator.html
http://www.bunkus.org/videotools/mkvtoolnix/
It could also be a bug in VLC itself.
--
Thiago
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list