This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Data loss of around 3 sec at start of every capture [DM8168 ]

Other Parts Discussed in Thread: TFP401A-EP

Dear Group Members , 

Our requirement is to create an 5min file for 8hours continuously. 
So currently we are doing an pipeline start & stop after every 5min. Below is the details 

 A) We have build an Gst application for :- 
        Processor ( TI Netra DM8168) 
        Audio ( Stereo 16bit 44.1KHZ) 
        Video ( DVI 1080p @ 60hz using TFP401A-EP DVI receiver) 
        MUX  (MATROSKA) 
        Overlay ( Time ) 
        Filesink as ".avi" 


B) We are loosing around 1.7sec at the start of every capture. Let me explain 
     If we put the pipeline in PLAYING mode at t=0 for total duration of 100 sec , the recordded file has below mentioned status :- 
        a) Video from t=0 to t=3 sec is not captured in the recorded file . 
        b) The recorded file has first frame of video  from t=3 sec to t=103 sec 


C)  This data loss of initial 3sec is observed every time i start & stop the engine. 

D) The basic flow is :- 
     a) Creating the pipeline with the elements and linking them in main thread . 
           gst_bin_add_many(GST_BIN(pipeline), AVIMux, FileSink,NULL); 
           gst_bin_add_many(GST_BIN(pipeline), omx_videosrc, clockoverlay, omx_videoEnc,NULL); 
           gst_element_link_many(omx_videosrc, clockoverlay,omx_videoEnc, AVIMux, NULL); 
           gst_bin_add(GST_BIN(pipeline), alsaAudSrc); 
           gst_element_link(alsaAudSrc, AVIMux); 
           gst_element_link(AVIMux, FileSink); 

           if (TRUE != gst_pipeline_set_clock(pipeline, gst_system_clock_obtain())) { 
                printf("gst_pipeline_set_clock(GstSystemClock) did not work\n"); 
                nRetVal = FAILURE; 
                goto labelExit; 
           } 



     b) Create an child thread and do the below mentioned activities ( rough flow ):- 
             GSource *bus_source; 
             GstBus *bus; 
             main_loop_cntxt = g_main_context_new(); 
             g_main_context_push_thread_default(main_loop_cntxt); 
             bus = gst_element_get_bus (pipeline); // Pipeline is created in parent thread 
             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, main_loop_cntxt); 
             g_source_unref (bus_source); 
             g_signal_connect (G_OBJECT (bus), "message::eos", (GCallback)eos_cb, NULL); 
             main_loop = g_main_loop_new(main_loop_cntxt, FALSE); 
             gst_element_set_state (pipeline, GST_STATE_PLAYING); 

             if (gst_element_get_state (pipeline, NULL, NULL, (GST_SECOND * 15)) == GST_STATE_CHANGE_FAILURE){ 
                        goto exit_label; 
             } 
             g_main_loop_run (main_loop); 



So could team members please let me know where should we debug and probable point of problem. 

Thanks , 
Ashish Kumar Mishra.

  • Hello,

    Are you moving the pipeline to stop state?
    What about on every X seconds/minutes to move it not to stop to pause state ? There is no need to move all the elements to stop state, you could dynamically try to reconnect the last element only for example.
    It is normal to observer data lost when you moving the pipeline from playing to stop and then stop to playing state.

    Correct me if my understanding is wrong, please.

    BR
    Margarita
  • Dear Margarita ,

    Thanks for your valuable input :-
    1) Yes the requirement is to create file chunks , currently we are stopping the engine after every 5min and then re-strating the pipeline
    which create the elements again.

    2) Yes we are observing the data loss when we stop and then start again.

    3) ".. There is no need to move all the elements to stop state, you could dynamically try to reconnect the last element only for example..."
    I am new to gstreamer , hence the code is an basic replica of what i could figure from the Gstreamer documentation
    Hence , could you please provide some pointer's by which i could understand how can i dynamically reconnect the last element .


  • Hello,

    You could use also output-selector element. This element has one input and two outputs. One every x time the first output could be connected to the fakesink the second output could be connected to the filesink element. So in this case there is no need to move the pipeline in stop state to avoid the init again and loosing frames.

    BR
    Margarita

  • Dear Margarita ,

    I would look at the same and try to search for any sample.
    Could you please share any sample code for this element , as i am new to gst.


    Basic serach returned below sample code :-
    gstreamer-devel.966125.n4.nabble.com/sample-using-output-selector-td3794948.html
    code.google.com/.../output-selector-test.c

    Could you please let me know if these i can use as reference.
  • Hello,

    This could help it is the call back func

    static GstPad *osel_src1 = NULL;
    static GstPad *osel_src2 = NULL;


    static gboolean
    switch_cb (gpointer user_data)
    {
    CustomData data;
    GstElement *sel = GST_ELEMENT (user_data);
    GstPad *old_pad, *new_pad = NULL;

    g_object_get (G_OBJECT (sel), "active-pad", &old_pad, NULL);


    if (old_pad == osel_src1)
    {
    new_pad = osel_src2;

    }
    else
    {
    new_pad = osel_src1;


    }

    g_object_set (G_OBJECT (sel), "active-pad", new_pad, NULL);

    g_print ("switched from %s:%s to %s:%s\n", GST_DEBUG_PAD_NAME (old_pad),
    GST_DEBUG_PAD_NAME (new_pad));


    gst_object_unref (old_pad);

    return TRUE;

    }


    Where the elements are link:

    gst_element_link_pads (data.osel, "src", data.filesink, "sink");
    gst_element_link_pads (data.osel, "src", data.fakesink, "sink");

    to link the pads. Something like this should work.

    Keep in mind that in EZSDK we use gstreamer 0.10.

    I will check the links which you share. I would recommend you to check this element also is it suitable for your requirement.
    This and the suggestion for dynamic link and unlink elements will avoid to move the pipeline in stop state.


    BR
    Margarita

  • Extremely thankful Margarita !!!!!!
    I would take this as a reference and try to test with our existing implementation.

    Would share the outcome of it....thanks a lot
  • Hello,

    Let me know the result the another solution could be to dynamical link and unlink the last element to connect one time filesink one time fakesink.

    But in this unlink/link probably there ll be observe framedrop since in this case the only the last element should be moved to pause and stop and then again to playing but it will takes less then ~3 seconds since this operations will be only on one element not on the pipeline.

    BR

    Margarita

  • Hi Team ,

    1) I tried making the pipeline element of file-sink as dynamic but , only 1st file created by the pipeline is playable.
    The other recorded file are having data but fails to play stating "......COULD NOT DETERMINE TYPE OF STREAM ....... "

    2) I even tired the logic of dynamic pipeline using VIDEOTESTSRC element in the plugin .
    I have initiated an thread on GSTREAMER forum for the same with the test sample code.
    gstreamer-devel.966125.n4.nabble.com/Dynamic-Pipeline-Vidoetestsrc-element-works-but-Filesink-element-fails-td4674638.html

    3) Also while evaluating the probable solution we figured an element of "splitmuxsink " doing the required task
    ( working with latest version of Gstreamer1.6.1 ).

    Could you please share an equivalent of "splitmuxsink element in Gstreamer 1.6.1 " that we could replace with "filesink element in
    Gstreamer 0.10".
    or
    Or could group member share any sample code for dynamically program MUX + FILESINK in Gstremer0.10.


  • Dear Margarita Gashova ,

    Sorry for lot of delay in reverting back on thread.
    Please note that after trying all the options , the approach of "making the handling of pad's dynamically " is the preferred one.
    I am able to create an P.O.C of the same on Gstreamer-1.0 which now i would be down porting to lower version of gstreamer-0.10

    I thank for your valuable input as that was the first light following which we could at least derive an P.O.C at least on Gstreamer-1.0
  • Hello Ashish Kumar Mishra ,

    I am glad to hear this.
    Let us know if you have further questions.

    BR
    Margarita