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.

Playback speed in DM385 or TI814x

Other Parts Discussed in Thread: DM385

Hi,

I'm Working  mp4 playback using GStreamer Media Player Application in DM385 target board

I'm trying to implement Forward and backward the video streams. Anyone can share the idea to implement ?

Thanks,

Rajesh Kannan S

  • Hello,

    You want to implement the seek functionality(gst_element_seek)?

    Best Regards,

    Margarita

  • Hi Margarita,

    Yes, But  in my code I'm not using the mainloop (ie) GMainLoop *loop; Instead of using create_pipeline() function.

    How to implement the seek functionality in my target ?

    Regards,

    Rajesh Kannan.S

  • Hello,

    Rajesh Kannan said:
    Anyone can share the idea to implement ?

    You could try to use gst_element_seek.

    Best Regards,

    Margarita

  • Hi,

    You can refer to this sample application, http://docs.gstreamer.com/display/GstSDK/Basic+tutorial+13%3A+Playback+speed

    Thanks,

    --Prabhakar Lad

  • Hi Prabhakar,

    Thanks for your reply....

    I want to perform the seek functionlity in DM385 board.. It is possible to get use without handle keyboard function

    Regards,

    Rajesh Kannan.S

  • Hi,

    On what event do you want to perform the seek operation ?

    Thanks,

    --Prabhakar Lad

  • Hi,

    I want both forward and backward seek events to play the  video streams...

    Regards,

    Rajesh kannan.S

  • Hi,

    I meant on what event/trigger/call (for example key events) do you want to perform the seek ?

    Thanks,

    --Prabhakar Lad

  • Hello Rajesh,

    Here is example function:

    /* Adding random seek for test purpose*/
    gboolean cb_timeout (gpointer data){
        
        GstElement *pipeline = (GstElement *) data;
        GstFormat fmt = GST_FORMAT_TIME;
        gboolean seek;
        gint64 len;
        gint64 len_seconds;
        
            
        seek = gst_element_seek(pipeline, 1.0, GST_FORMAT_TIME,

                         GST_SEEK_FLAG_FLUSH,                                               // | GST_SEEK_FLAG_KEY_UNIT,

                         GST_SEEK_TYPE_SET,   pos * GST_SECOND,           //10 * GST_SECOND,

                         GST_SEEK_TYPE_NONE, -1 );         
                         
     
        printf ("seek %d\n", seek);
        
        seek = gst_element_query_duration(pipeline, &fmt, &len);
        len_seconds = len/GST_SECOND;
        printf ("Total time: %lld (%lld)\n", len, len_seconds);
        pos =   g_random_int_range (0, len_seconds);
        printf ("Seek in seconds: %d\n", pos);
        puts("Timeout called");
        return TRUE;

    }

    ......

    int main (int argc, char *argv[]){

    ....

     g_timeout_add(10 * 1000, cb_timeout, pipeline);

    }

    g_random_int_range returns a random number, you should change this for your purpose.

    g_timeout_add  has parameters:

    interval

    the time between calls to the function, in milliseconds (1/1000ths of a second)

     

    function

    function to call

     

    data

    data to pass to function

     

    The function is called repeatedly until it returns FALSE, at which point the timeout is automatically destroyed and the function will not be called again. The first call to the function will be at the end of the first interval .

    This is just an example without to waiting the keyboard event.

    Best Regards,

    Margarita

  • Hi Margarita,

    Thanks for your reply,

    Now I'm integrating with GUI.. I'm getting command from UI (ex : 5 )(not using keyboard)  I'll write one function to perform forward playback...

    After getting seek position and all then how to perform the action ( To write function depends on data rate to multiply by 2 )

    Regards,

    Rajesh Kannan.S

  • Hi  Margarita,

    Your function is working fine. But what I want is to forward or reverse the streams in a sequence manner

    For ex :- Normal playback rate is 1, then to increase  the speed (ie) 2.0 like that. It is possible to change or convert your code ?

     

    Regards,

    Rajesh Kannan.S

  • Hi,

    Use the below code which runs at 1x speed for 1st 10 seconds and then 2x for next 10 seconds and again switches back to 1x and this continues.

    static gdouble rate = 1.0;

    /* Adding random seek for test purpose*/
    gboolean cb_timeout (gpointer data){
        
        GstElement *pipeline = (GstElement *) data;
        GstFormat fmt = GST_FORMAT_TIME;
        gboolean seek;
        gint64 len;
        gint64 len_seconds;
        
            
        seek = gst_element_seek(pipeline, rate, GST_FORMAT_TIME,

                         GST_SEEK_FLAG_FLUSH,                                               // | GST_SEEK_FLAG_KEY_UNIT,

                         GST_SEEK_TYPE_SET,   pos * GST_SECOND,           //10 * GST_SECOND,

                         GST_SEEK_TYPE_NONE, -1 );         
                         
      rate = 2.0;


        printf ("seek %d\n", seek);
        
        seek = gst_element_query_duration(pipeline, &fmt, &len);
        len_seconds = len/GST_SECOND;
        printf ("Total time: %lld (%lld)\n", len, len_seconds);
        pos =   g_random_int_range (0, len_seconds);
        printf ("Seek in seconds: %d\n", pos);
        puts("Timeout called");
        return TRUE;

    }

    Thanks,

    --Prabhakar Lad

  • Hi Prabhakar,

    I want to forward the streams exactly 2.0 (Forward x2) not to run in random.

    From start to end of the stream it will go to forward 2.0  (Normal playback rate is 1.0)

    Regards,

    Rajesh Kannan.S

     

  • Hello,

    This was an example for random run. You should make some changes like:

    Remove the g_random_int_range function if you do not want to not run in random.

    Best Regards,

    Margarita