Gstreamer Concat command line to code?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Gstreamer Concat command line to code?

killerrats

do you have to link the elements a certain way? can i just take each of the elements and connect them accordingly or no? I have converted command line to code before but this one I wondered if it works differently.

gst-launch-1.0 -e concat name=c ! h264parse ! mp4mux name=mux ! filesink location=testing.mp4 concat name=c2 ! aacparse ! mux.audio_1 filesrc location=[1] ! qtdemux name=dem1 ! queue ! c. dem1.audio_0 ! queue ! c2. filesrc location=[2] ! qtdemux name=dem2 ! queue ! c. dem2.audio_0 ! queue ! c2. filesrc location=[3] ! qtdemux name=dem3 ! queue ! c. dem3.audio_0 ! queue ! c2. filesrc location=[4] ! qtdemux name=dem4 ! queue ! c. dem4.audio_0 ! queue ! c2.

------------------------------
Gstreamer 1.14.4
------------------------------
Windows


Sent from the GStreamer-devel mailing list archive at Nabble.com.

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
------------------------------
Gstreamer 1.14.4
------------------------------
Windows
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer Concat command line to code?

Nicolas Dufresne-5
Le mercredi 31 octobre 2018 à 12:30 -0500, killerrats a écrit :

> do you have to link the elements a certain way? can i just take each
> of the elements and connect them accordingly or no? I have converted
> command line to code before but this one I wondered if it works
> differently.
> gst-launch-1.0 -e concat name=c ! h264parse ! mp4mux name=mux ! filesink location=testing.mp4 \
>                   concat name=c2 ! aacparse ! mux.audio_1 \
>                   filesrc location=[1] ! qtdemux name=dem1 ! queue ! c. \
>                     dem1.audio_0 ! queue ! c2. \
>                   filesrc location=[2] ! qtdemux name=dem2 ! queue ! c. \
>                     dem2.audio_0 ! queue ! c2. \
>                   filesrc location=[3] ! qtdemux name=dem3 ! queue ! c. \
>                     dem3.audio_0 ! queue ! c2. \
>                   filesrc location=[4] ! qtdemux name=dem4 ! queue ! c. \
>                     dem4.audio_0 ! queue ! c2.
Yes, the order of linking on concat will impact in order they will be
concatenated. I don't know if you can trust the parser here. If you mix
up the linking, this pipeline will also stall.

Another note, this pipeline can only work if both audio/video tracks in
each source files are exactly the same duration (they are often not).

Nicolas

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (201 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Gstreamer Concat command line to code?

killerrats
In reply to this post by killerrats
Success on building the pipeline to code. Just have to put each filesrc
elements in a list and pass to the pad-added function from demux and works.
Have to also connect the queue to the concat elements audio and video side.
There is a limit on storage because it seems to halt at a certain time. have
to figure that out. seems to be at different amounts of storage. it could do
10 files with 10 megabytes each. Different time I could only combine 3 of 50
megabyte files. So don't know what the difference is. Any one know?

class filesrcElements
        {
        public:
                GstElement* filesrc
                ,* qtdemux
                ,* queue1
                ,* queue2;
                std::string queue1Name, queue2Name, qtdemuxName,
filesrcName,filesrcLocation;
        };
bool VideoPipeline::SetupFilesrcElements()
{
        if (this->aFiles.size() == 0)
                return false;

        GstPad* srcPad, *sinkPad;
        GstElement* concat = gst_bin_get_by_name(GST_BIN(this->srcPipeline),
"concat1")
        ,* concat2 = gst_bin_get_by_name(GST_BIN(this->srcPipeline),"concat2");

        std::string filesrcPipe;
        std::list<std::string>::iterator it = this->aFiles.begin();
        unsigned int index = 0;

        for (; it != this->aFiles.end(); it++)
        {
                AddToConsoleOutputList("File: " + *it);
                ++index;
                filesrcElements file;
                ++this->concatPadNumber;
                ++this->queueCount;
                std::string demuxName = "dem" + std::to_string(index);
                std::string filesrcName = "filesrc" + std::to_string(index);
                std::string queue1Name = "queue" + std::to_string(queueCount);
                ++queueCount;
                std::string queue2Name = "queue" + std::to_string(queueCount);
                file.filesrcName = filesrcName;
                file.qtdemuxName = demuxName;
                file.queue1Name = queue1Name;
                file.queue2Name = queue2Name;

                file.queue1 = this->AssignElement("queue", queue1Name);
                file.queue2 = this->AssignElement("queue", queue2Name);
                file.filesrc = this->AssignElement("filesrc", filesrcName);
                file.qtdemux = this->AssignElement("qtdemux", demuxName);

                g_object_set(G_OBJECT(file.filesrc), "location", (*it).c_str(), NULL);
                gst_bin_add_many(GST_BIN(this->srcPipeline), file.filesrc,
file.qtdemux,file.queue1,file.queue2, NULL);

                gst_element_link(file.filesrc, file.qtdemux);

                sinkPad = gst_element_get_request_pad(concat,
("sink_"+std::to_string(concatPadNumber)).c_str());
                srcPad = gst_element_get_static_pad(file.queue1, "src");
                gst_pad_link(srcPad, sinkPad);
                gst_object_unref(srcPad);
                gst_object_unref(sinkPad);

                sinkPad = gst_element_get_request_pad(concat2, ("sink_" +
std::to_string(concatPadNumber)).c_str());
                srcPad = gst_element_get_static_pad(file.queue2, "src");
                gst_pad_link(srcPad, sinkPad);
                gst_object_unref(srcPad);
                gst_object_unref(sinkPad);

                //list so gstreamer has reference to
                this->filesSources.push_back(file);

                // signal from demux and pass the file that was just added
to be connected to queues
                g_signal_connect(file.qtdemux, "pad-added",
G_CALLBACK(qtdemux_pad_added_cb), &this->filesSources.back());
        }
       
        return true;
}
void VideoPipeline::qtdemux_pad_added_cb(GstElement* element,
        GstPad* pad,
        gpointer user_data)
{
        gchar *name;
        GstCaps * p_caps;
        GstElement* nextElement = NULL;
        filesrcElements* file = static_cast<filesrcElements*>(user_data);
        name = gst_pad_get_name(pad);
        //g_print("A new pad %s was created\n", name);
        p_caps = gst_pad_get_pad_template_caps(pad);

        if (strstr(name, "video") != NULL)
        {
                std::cout << "\n------------------------ Video
-------------------------------\n";
               
                        if (!gst_element_link_pads_filtered(element, name,file->queue1 ,
"sink",p_caps))
                        {
                                std::cout << "\nFailed to link video element to src to sink\n";
                        }
        }
        else if (strstr(name, "audio") != NULL)
        {
                std::cout << "\n------------------------ Audio
-------------------------------\n";
                if (!gst_element_link_pads_filtered(element, name, file->queue2, "sink",
p_caps))
                {
                        std::cout << "\nFailed to link video element to src to sink\n";
                }
        }
        g_free(name);
        gst_caps_unref(p_caps);
}



-----
------------------------------
Gstreamer 1.14.4
------------------------------
Windows
--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
------------------------------
Gstreamer 1.14.4
------------------------------
Windows