(no subject)

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

(no subject)

Johan Basore
Hello,

I am building a video editing app for iOS with gstreamer 1.8.1.
But I am having a problem with decodebin( especially demux).
It says "Error received from element avidemux0 : Internal data stream error.".
All types of movies have problem with demux.

Here are my source codes.

    GstBus *bus;
    GSource *bus_source;

    GstElement *source1, *clrspace1, *clrspace2, *clrspace, *videobox1, *sink, *source2, *mpegenc, *avimux;
    GstElement *videomixer;
    GstElement *decodebin1, *decodebin2;
    GstElement *queue;
    //GstElement *matroskademux1, *vorbisdec, *audioconvert, *audioresample, *audiosink;
    //GstElement *matroskademux1, *vp8dec1, *matroskademux2, *vp8dec2;
    
    
    GST_DEBUG ("Creating pipeline");
    
    /* Create our own GLib Main Context and make it the default one */
    context = g_main_context_new ();
    g_main_context_push_thread_default(context);
/****************************************************************************************************************************/
    /* Build pipeline */
    pipeline = gst_pipeline_new("pipelinecomposer");
    source1 = gst_element_factory_make("filesrc", "source1");
    source2 = gst_element_factory_make("filesrc", "source2");
    videobox1 = gst_element_factory_make("videobox", "videobox");
    videomixer = gst_element_factory_make("videomixer", "videomixer");
    clrspace1 = gst_element_factory_make("videoconvert", "clrspace1");
    clrspace2 = gst_element_factory_make("videoconvert", "clrspace2");
    clrspace = gst_element_factory_make("videoconvert", "clrspace");
    sink = gst_element_factory_make("filesink", "sink");
    mpegenc = gst_element_factory_make("x264enc", "mpegenc");
    avimux = gst_element_factory_make("mpegtsmux", "avimux");
    decodebin1 = gst_element_factory_make("decodebin", "decodebin1");
    decodebin2 = gst_element_factory_make("decodebin", "decodebin2");
    queue = gst_element_factory_make("queue", "queue");
        
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"1.avi"];
    
    NSString *filePath_1 = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"1.webm"];
    NSString *filePath_2 = [NSString stringWithFormat:@"%@/%@", documentsDirectory, @"2.webm"];
    
    g_object_set (source1, "location", [filePath_1 UTF8String], NULL);
    g_object_set (source2, "location", [filePath_2 UTF8String], NULL);
    
    g_object_set (G_OBJECT (sink), "location", [filePath UTF8String], NULL);
    
    if (!mpegenc || !avimux) {
        GST_DEBUG("No Enc");
    }
    if (!sink) {
        GST_DEBUG ("No Sink");
    }
    
    if (!decodebin1) {
        GST_DEBUG ("No Decodebin");
    }
    
    /*
    g_object_set(videobox1,"border-alpha",0,"top",0,"left",0,NULL);
    
    gst_bin_add_many(GST_BIN (pipeline), source1, sink, videobox1, videomixer, clrspace1, clrspace2, clrspace, source2, mpegenc, avimux, decodebin1, decodebin2, nil);
    
    gst_element_link_many(source1, decodebin1, clrspace1, videobox1, videomixer, clrspace, mpegenc, avimux, sink, nil);
    gst_element_link_many(source2, decodebin2, clrspace2, videomixer, nil);
    */
    gst_bin_add_many(GST_BIN (pipeline), source1, sink,  clrspace1, mpegenc, avimux, decodebin1, queue, nil);
    
    gst_element_link_many(source1, decodebin1, queue, clrspace1, mpegenc, avimux, sink, nil);
    
    gst_element_set_state(pipeline, GST_STATE_PLAYING);
    
/****************************************************************************************************************************/
    /* Instruct the bus to emit signals for each received message, and connect to the interesting signals */
    bus = gst_element_get_bus (pipeline);
    bus_source = gst_bus_create_watch (bus);
    g_source_set_callback (bus_source, (GSourceFunc) gst_bus_async_signal_func, NULL, NULL);
    g_source_attach (bus_source, context);
    g_source_unref (bus_source);
    g_signal_connect (G_OBJECT (bus), "message::error", (GCallback)error_cb, (__bridge void *)self);
    g_signal_connect (G_OBJECT (bus), "message::state-changed", (GCallback)state_changed_cb, (__bridge void *)self);
    gst_object_unref (bus);
    
    /* Create a GLib Main Loop and set it to run */
    GST_DEBUG ("Entering main loop...");
    main_loop = g_main_loop_new (context, FALSE);
    g_main_loop_run (main_loop);
    GST_DEBUG ("Exited main loop");
    g_main_loop_unref (main_loop);
    main_loop = NULL;
    
    /* Free resources */
    g_main_context_pop_thread_default(context);
    g_main_context_unref (context);
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (pipeline);


Can you help me?
My Xcode version is 7.2 and iOS version is 8.1 and 9.2.

Thanks

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

Re: decodebin problems

Tim Müller
On Fri, 2016-04-22 at 18:28 +0000, Johan Basore wrote:

Hi Johan,

> I am building a video editing app for iOS with gstreamer 1.8.1.

I wonder if you are aware of the gst-editing-services (ges) library
which is also what the Pitivi video editor uses. It takes care of a lot
of heavy lifting for you.


> But I am having a problem with decodebin( especially demux).
> It says "Error received from element avidemux0 : Internal data stream
> error.".

When you get an error message on the bus, it's usually useful to also
print the 'debug' string from the error message, it will provide more
details. My guess is that here it probably said something about
'streaming stopped: not-linked'.

> All types of movies have problem with demux.
    

>     gst_element_link_many(source1, decodebin1, clrspace1, videobox1,
> videomixer, clrspace, mpegenc, avimux, sink, nil);
>     gst_element_link_many(source2, decodebin2, clrspace2, videomixer,
> nil);
>     */
>     gst_bin_add_many(GST_BIN (pipeline), source1, sink,  clrspace1,
> mpegenc, avimux, decodebin1, queue, nil);
>     gst_element_link_many(source1, decodebin1, queue, clrspace1,
> mpegenc, avimux, sink, nil);
>   

I suspect that linking decodebin to the elements to the right fails.

This is because decodebin has initially no source (output) pads yet. It
will only add those output pads later once data flow start (i.e. once
you set the pipeline to PAUSED or PLAYING state).

So you can't link decodebin to the next element here yet at this point.

You have to connect to decodebin's "pad-added" signal an then in the
signal callback function you can link the new pad to the next element
(if it's the right kind of pad).

Cheers
 -Tim

PS: please try to add a subject next time


--
Tim Müller, Centricular Ltd - http://www.centricular.com


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