How can I make a playbin2 to jump to the last video frame and display it?

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

How can I make a playbin2 to jump to the last video frame and display it?

wl2776
Administrator
I would like my playbin2 to perform "Go End" command - display the last video frame in the loaded file.
Here is how I create the playbin:

m_player = gst_element_factory_make("playbin2","playbin0");
GstElement *bus = (GstElement *)gst_pipeline_get_bus(GST_PIPELINE(m_player));
gst_bus_set_sync_handler (GST_BUS(bus), (GstBusSyncHandler)gst_bus_sync_handler, this);
gst_bus_add_watch (GST_BUS(bus), bus_call, this);
gst_object_unref(bus);
m_loop = g_main_loop_new(NULL,FALSE);

if(!m_videosink){
        m_videosink = gst_element_factory_make("directdrawsink","videosink");
        if(m_videosink){
                g_object_set(m_videosink,"sync",TRUE,NULL);
                gst_x_overlay_set_xwindow_id (GST_X_OVERLAY (m_videosink),m_hwnd);
                        g_object_set(G_OBJECT(m_player),"video-sink",m_videosink,NULL);
        }
}
g_object_set(G_OBJECT(m_player),"uri", g_locale_to_utf8(filename,-1,NULL,NULL,NULL),NULL);

gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_PLAYING);

And here is how I currently jump to the end.

gst_element_seek_simple(GST_ELEMENT(m_player),
                GST_FORMAT_TIME,
                (GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
                m_stream_duration);
gst_element_get_state(GST_ELEMENT(m_player),NULL,NULL,100 * GST_MSECOND);
gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_PAUSED);

I've turned on the debug messages (--gst-debug=playbin2:5,playbin:5), however, I don't see anything, when seeking functions are called.
Reply | Threaded
Open this post in threaded view
|

Re: How can I make a playbin2 to jump to the last video frame and display it?

wl2776
Administrator
Yes!
I've done it!
To those, who's interested, my solution is

void gst_player::go_end()
{
  if(m_player){
    gboolean rb;
    int attempts=0;
    do {
      rb=gst_element_seek(GST_ELEMENT(m_player),-1.0,
                  GST_FORMAT_TIME,(GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
                  GST_SEEK_TYPE_SET,0,GST_SEEK_TYPE_END,0);
      if(!rb) Sleep(100);
    }while(!rb || ++attempts>3);
               
    if(rb){
        gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_PLAYING);
    }
  }
}

This makes the playbin2 to display the last frame.
In all other cases, I've tried, it successfully positioned to the end of file, but didn't draw the last frame.
Reply | Threaded
Open this post in threaded view
|

Re: How can I make a playbin2 to jump to the last video frame and display it?

wl2776
Administrator
Further studies have shown, that this doesn't work on all files. I tried avi and mpeg-2 PS files.
I am still looking for reliable solution.
I am developing a medial player with GStreamer, in windows. My task is to make it to jump to the end of file and display the last frame.

I use playbin2 with directdraw videosink.

wl2776 wrote
void gst_player::go_end()
{
  if(m_player){
    gboolean rb;
    int attempts=0;
    do {
      rb=gst_element_seek(GST_ELEMENT(m_player),-1.0,
                  GST_FORMAT_TIME,(GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
                  GST_SEEK_TYPE_SET,0,GST_SEEK_TYPE_END,0);
      if(!rb) Sleep(100);
    }while(!rb || ++attempts>3);
               
    if(rb){
        gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_PLAYING);
    }
  }
}

This makes the playbin2 to display the last frame.
In all other cases, I've tried, it successfully positioned to the end of file, but didn't draw the last frame.
Reply | Threaded
Open this post in threaded view
|

Re: How can I make a playbin2 to jump to the last video frame and display it?

Kapil Agrawal
Not sure what could be the exact usage of same?
But if we just jump to last frame it might happen that last frame is a black (probablity is high) , will still it be useful.

-kapil

On Sat, Feb 27, 2010 at 9:37 PM, wl2776 <[hidden email]> wrote:

Further studies have shown, that this doesn't work on all files. I tried avi
and mpeg-2 PS files.
I am still looking for reliable solution.
I am developing a medial player with GStreamer, in windows. My task is to
make it to jump to the end of file and display the last frame.

I use playbin2 with directdraw videosink.


wl2776 wrote:
>
> void gst_player::go_end()
> {
>   if(m_player){
>     gboolean rb;
>     int attempts=0;
>     do {
>       rb=gst_element_seek(GST_ELEMENT(m_player),-1.0,
>
> GST_FORMAT_TIME,(GstSeekFlags)(GST_SEEK_FLAG_FLUSH|GST_SEEK_FLAG_ACCURATE),
>                   GST_SEEK_TYPE_SET,0,GST_SEEK_TYPE_END,0);
>       if(!rb) Sleep(100);
>     }while(!rb || ++attempts>3);
>
>     if(rb){
>         gst_element_set_state(GST_ELEMENT(m_player),GST_STATE_PLAYING);
>     }
>   }
> }
>
> This makes the playbin2 to display the last frame.
> In all other cases, I've tried, it successfully positioned to the end of
> file, but didn't draw the last frame.
>

--
View this message in context: http://n4.nabble.com/How-can-I-make-a-playbin2-to-jump-to-the-last-video-frame-and-display-it-tp1567156p1572038.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
http://www.linkedin.com/in/kapilagrawal

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How can I make a playbin2 to jump to the last video frame and display it?

wl2776
Administrator
Kapil Agrawal wrote
Not sure what could be the exact usage of same?
But if we just jump to last frame it might happen that last frame is a black
(probablity is high) , will still it be useful.
For example, video editing. If we have a part of a video stream, saved (remuxed) to a file, for example the whole news translation and want to have one topic, exactly cut from the whole stream.
Anyway, I have this task, my customers want this option, I, actually, don't care very much, how they use this. And I would appreciate if the community helps me with finding a reliable solution.