Split into ogg files
Tim-Philipp Müller
t.i.m at zen.co.uk
Fri Mar 25 14:53:48 UTC 2022
On Fri, 2022-03-25 at 14:35 +0000, Diogo Rodrigues wrote:
Hi,
> 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:
>
mux.audio_%u means "link to the element named mux" (we named it with
splitmuxsink name=mux)
The audio_%u part is the name of a pad template (gst-inspect-1.0
splitmuxsink), so you're basically telling the gst-launch engine what
request pad to request from splitmuxsink.
If you're using GStreamer 1.20 you can use
src_pad = gst_element_get_static_pad(identity, "src");
sink_pad = gst_element_request_pad_simple(splitmuxsink, "audio_%u");
pad_link_return = gst_pad_link(src_pad, sink_pad);
pad_link_return is an enum, not a boolean for what it's worth. Also
make sure the elements have been added to the pipeline/bin before
linking them.
> g_object_set(identity, "drop-buffer-flags",
> GST_BUFFER_FLAG_HEADER, NULL);
In this case this works, but in general flags properties are a bit
tricky because the enum is usually not public. You can use the numbers
you see in gst-inspect-1.0 identity (0x400), or you can use
gst_util_set_object_arg(identity, "headers");
> g_object_set(sink, "max-size-time", 10000000000 NULL);
This is a 64-bit integer, so best to use (guint64) 10000000000 or
G_GUINT64_CONSTANT(10000000000), or (guint64) 10 * GST_SECOND.
g_object_set() is a vararg function that will fail in interesting ways
if you don't pass the exact type that it expects for the property.
> 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)
It doesn't look like you have the identity in here? (Not that it
matters for making linking work)
I think you'll have to link like I suggested above (code untested
though), so it creates a request pad with the right pad template.
Cheers
Tim
More information about the gstreamer-devel
mailing list