Split into ogg files
Diogo Rodrigues
dmfrodrigues2000 at gmail.com
Fri Mar 25 10:01:41 UTC 2022
Hello!
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). Could you please point out what I'm
missing?
Here's the complete C code of the pipeline:
===
GstElement *source = gst_element_factory_make("filesrc", "source");
GstElement *parser = gst_element_factory_make("mpegaudioparse",
"parser");
GstElement *decoder = gst_element_factory_make("avdec_mp3",
"decoder");
GstElement *converter = gst_element_factory_make("audioconvert",
"converter");
GstElement *encoder = gst_element_factory_make("vorbisenc",
"encoder");
GstElement *oggmux = gst_element_factory_make("oggmux", "oggmux");
GstElement *filesink = gst_element_factory_make("filesink",
"filesink");
GstElement *bin = gst_bin_new("bin");
GstElement *sink = gst_element_factory_make("splitmuxsink",
"sink");
GstElement *pipeline = gst_pipeline_new("test-pipeline");
if (!pipeline || !source || !parser || !decoder || !converter ||
!encoder || !oggmux || !filesink || !bin || !sink) {
g_printerr("Not all elements could be created.\n");
*ret = -1; return ret;
}
g_object_set(source, "location", "audio.mp3", NULL);
gst_bin_add_many(GST_BIN(bin), oggmux, filesink, NULL);
if(gst_element_link_many(oggmux, filesink, NULL) != TRUE) {
g_printerr("Not all elements could be linked in the encoder
bin.\n");
gst_object_unref(bin);
gst_object_unref(pipeline);
*ret = -1; return ret;
}
GstPad *sink_pad = gst_element_get_static_pad (oggmux, "sink");
GstPad *ghost_sink_pad = gst_ghost_pad_new_from_template ("bin-sink",
sink_pad, gst_pad_get_pad_template(sink_pad));
gst_pad_set_active (ghost_sink_pad, TRUE);
gst_element_add_pad (bin, ghost_sink_pad);
gst_object_unref (sink_pad);
g_object_set(sink, "location", "out_%d.ogg", NULL);
g_object_set(sink, "muxer", encoder, NULL);
g_object_set(sink, "sink", bin, NULL);
g_object_set(sink, "max-size-time", 10000000000 NULL);
gst_bin_add_many(GST_BIN(pipeline), source, parser, decoder, converter,
sink, NULL);
if (gst_element_link_many(source, parser, decoder, converter, sink,
NULL) != TRUE) {
g_printerr("Not all elements could be linked.\n");
gst_object_unref(pipeline);
*ret = -1; return ret;
}
===
Using gstreamer v1.20.1 compiled from source
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220325/369ce24f/attachment.htm>
More information about the gstreamer-devel
mailing list