Split into ogg files

Diogo Rodrigues dmfrodrigues2000 at gmail.com
Fri Mar 25 14:35:12 UTC 2022


Thanks a lot, that's good to know (it was not actually what I was asking,
but will prove very useful).

I'm still getting started with GStreamer so I'm not very used to its syntax
or workings. Namely, I do need to implement the pipeline in C (although I
know there is a C function that can interpret a string description of a
gst-launch pipeline, but I'd prefer to do everything in C).I am having
trouble translating the last part to C:

mux.audio_%u splitmuxsink muxer-factory=oggmux name=mux
max-size-time=10000000000 location=file-%02u.ogg

More specifically, the parts "mux.audio_%u" and "muxer-factory=oggmux
name=mux", I can't understand what they mean (even after reading gst-launch
docs, maybe I'm missing something, please bare with me). This is what I've
come up with so far, but it is clearly not working:

===
[...]
    GstElement *encoder   = gst_element_factory_make("vorbisenc",
"encoder");
    GstElement *identity  = gst_element_factory_make("identity",
"identity");
    GstElement *sink      = gst_element_factory_make("splitmuxsink",
"sink");

    GstElement *pipeline = gst_pipeline_new("test-pipeline");

    g_object_set(identity, "drop-buffer-flags", GST_BUFFER_FLAG_HEADER,
NULL);
    g_object_set(sink, "muxer-factory", "oggmux", NULL);
    g_object_set(sink, "max-size-time", 10000000000 NULL);

    gst_bin_add_many(GST_BIN(pipeline), source, parser, decoder, converter,
encoder, sink, NULL);
    if (gst_element_link_many(source, parser, decoder, converter, encoder,
sink, NULL) != TRUE) {
        gst_object_unref(pipeline);
        return -1;
    }
===

The debug log shows the following:

0:00:00.023683677    97 0x5560d44bd2a0 INFO                GST_PADS
gstpad.c:2532:gst_pad_link_full: link between encoder:src and sink:video
failed: no common format
0:00:00.023692657    97 0x5560d44bd2a0 INFO         splitgenmuxsink
gstsplitgenmuxsink.c:3292:gst_splitgenmux_sink_release_pad:<sink:video>
releasing request pad
0:00:00.023701245    97 0x5560d44bd2a0 INFO               GST_EVENT
gstpad.c:5946:gst_pad_send_event_unchecked:<queue_video:sink> Received
event on flushing pad. Discarding
0:00:00.023711442    97 0x5560d44bd2a0 INFO              GST_STATES
gstelement.c:2806:gst_element_continue_state:<queue_video> completed state
change to NULL

I believe it has to do with the fact the sink (presumably splitmuxsink) is
using a video pad template, and that's why you set name=mux (presumably to
name splitmuxsink as "mux") and added mux.audio_%d, to hint splitmuxsink to
instead use pad template audio_%d. Unfortunately I don't know nearly enough
to understand what's actually going on, or how to actually implement it in
C...

Any help would be appreciated!

On Fri, 25 Mar 2022 at 12:38, Tim-Philipp Müller <t.i.m at zen.co.uk> wrote:

> On Fri, 2022-03-25 at 10:01 +0000, Diogo Rodrigues via gstreamer-devel
> wrote:
>
> Hi,
>
> > I would like to create a pipeline that takes in a single mp3 audio
> > file and splits it into several 10-second vorbis/ogg files, but I'm
> > having issues linking the elements.
> >
> > I have already made a similar pipeline that takes a single mp3 audio
> > file and splits it into several 10-second mp3 files with Xing headers
> > by using lamemp3enc instead of vorbisenc, and xingmux instead of
> > oggmux. The mp3-to-mp3 pipeline works just fine, but the mp3-to-ogg
> > is not doing so well, because splitmuxsink is not being able to link
> > the muxer (vorbisenc) with the sink (oggmux+filesink).
>
> Theoretically splitmuxsink should be able to do just that.
>
> Unfortunately it looks like there's a bug in splitmuxsink that's
> specific to Vorbis/Ogg (vorbisenc will output a few header packets
> without a timestamp), so you get this:
>
> gst-launch-1.0 uridecodebin uri=file:///path/to/foo.mp3 ! audioconvert
> ! vorbisenc ! mux.audio_%u splitmuxsink muxer-factory=oggmux name=mux
>
> ERROR: from element /GstPipeline:pipeline0/GstSplitMuxSink:mux:
> Timestamping error on input streams
>
> Additional debug info:
> ../gst/multifile/gstsplitmuxsink.c(2594): handle_gathered_gop ():
> /GstPipeline:pipeline0/GstSplitMuxSink:mux:
> Queued GOP time is negative +99:99:99.999999999
>
> Needs fixing I'm afraid, but it looks like you can work around it with
> an identity element like this:
>
> gst-launch-1.0 uridecodebin uri=file:///path/to/foo.mp3 ! audioconvert
> ! vorbisenc ! identity drop-buffer-flags=header ! mux.audio_%u
> splitmuxsink muxer-factory=oggmux name=mux max-size-time=10000000000
> location=file-%02u.ogg
>
> Cheers
>  Tim
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220325/bd5d00b8/attachment.htm>


More information about the gstreamer-devel mailing list