How to make playbin to redraw frames on seek?

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

How to make playbin to redraw frames on seek?

wl2776
Administrator
Hi all.
My problem is that the playbin doesn't redraw video frames, when I try to seek in paused state.
I tried both playbin and playbin2 with the same result.

I am using the following code to play a video file.
player = gst_element_factory_make("playbin","playbin0"); 
GstElement *bus = (GstElement *)gst_pipeline_get_bus(GST_PIPELINE(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);

[ ... ]
// open and play a media file
g_object_set(G_OBJECT(player),"uri", g_locale_to_utf8(input->filename,-1,NULL,NULL,NULL),NULL);
gst_element_set_state(GST_ELEMENT(player),GST_STATE_PLAYING);
[ ... ]
I also have a slider in my application, which shows an overall playing progress and allows seeking. My condition is to pause the playback when a user clicks on it. Here is the function, processing events from that slider.
 
void CControlMainDialog::OnMarkerCtrlPosChange(LONG nPos)
{
  if(!player || !GST_CLOCK_TIME_IS_VALID(stream_duration)) return;
  gint64 nLLPos = (gint64)(stream_duration * nPos/MARKER_CTRL_SCALE) ;
  gst_element_seek_simple(GST_ELEMENT(player),GST_FORMAT_TIME,
                                    (GstSeekFlags)(GST_SEEK_FLAG_FLUSH | GST_SEEK_FLAG_KEY_UNIT),
                                    nLLPos);
  gst_element_get_state(GST_ELEMENT(player),NULL,NULL,100 * GST_MSECOND);
  gst_element_set_state(GST_ELEMENT(player),GST_STATE_PAUSED);
  UpdateToolbarState();
  repaint_video();
}

void CControlMainDialog::repaint_video()
{
  gst_x_overlay_expose(GST_X_OVERLAY(videosink));
}

The repaint_video method is called, I've added calls to OutputDebugString and seen the messages in the debug window.
However, it displays always the last displayed frame, not the frame the playbin is currently positioned on.
I tried digging the totem, however, it didn't help
Reply | Threaded
Open this post in threaded view
|

Re: How to make playbin to redraw frames on seek?

Julien Moutte-2
What video sink are you using ? It does not appear in your code sample.

You should not have to set the pipeline to PAUSED state after you issued the seek, but that can depend on the exact use case of your application though.

Best regards,

Julien Moutte,
FLUENDO S.A.


On Tue, Dec 22, 2009 at 10:51 AM, wl2776 <[hidden email]> wrote:

Hi all.
My problem is that the playbin doesn't redraw video frames, when I try to
seek in paused state.
I tried both playbin and playbin2 with the same result.

I am using the following code to play a video file.
player = gst_element_factory_make("playbin","playbin0");
GstElement *bus = (GstElement *)gst_pipeline_get_bus(GST_PIPELINE(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);

[ ... ]
// open and play a media file
g_object_set(G_OBJECT(player),"uri",
g_locale_to_utf8(input->filename,-1,NULL,NULL,NULL),NULL);
gst_element_set_state(GST_ELEMENT(player),GST_STATE_PLAYING);
[ ... ]

I also have a slider in my application, which shows an overall playing
progress and allows seeking. My condition is to pause the playback when a
user clicks on it. Here is the function, processing events from that slider.

void CControlMainDialog::OnMarkerCtrlPosChange(LONG nPos)
{
 if(!player || !GST_CLOCK_TIME_IS_VALID(stream_duration)) return;
 gint64 nLLPos = (gint64)(stream_duration * nPos/MARKER_CTRL_SCALE) ;
 gst_element_seek_simple(GST_ELEMENT(player),GST_FORMAT_TIME,
                                   (GstSeekFlags)(GST_SEEK_FLAG_FLUSH |
GST_SEEK_FLAG_KEY_UNIT),
                                   nLLPos);
 gst_element_get_state(GST_ELEMENT(player),NULL,NULL,100 * GST_MSECOND);
 gst_element_set_state(GST_ELEMENT(player),GST_STATE_PAUSED);
 UpdateToolbarState();
 repaint_video();
}

void CControlMainDialog::repaint_video()
{
 gst_x_overlay_expose(GST_X_OVERLAY(videosink));
}


The repaint_video method is called, I've added calls to OutputDebugString
and seen the messages in the debug window.
However, it displays always the last displayed frame, not the frame the
playbin is currently positioned on.
I tried digging the totem, however, it didn't help
--
View this message in context: http://n4.nabble.com/How-to-make-playbin-to-redraw-frames-on-seek-tp976820p976820.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to make playbin to redraw frames on seek?

wl2776
Administrator
Julien Moutte-2 wrote
What video sink are you using ? It does not appear in your code sample.
Video sink was generated automatically.
I've dumped an image using GST_DEBUG_BIN_TO_DOT_FILE, it appeared "videosink-actual-sink-dshowvideo".

Julien Moutte-2 wrote
You should not have to set the pipeline to PAUSED state after you issued the
seek, but that can depend on the exact use case of your application though.
This is a condition to my application, imposed by a client. The player has to pause playback when the slider is clicked.
Anyway, this doesn't matter. The player also has a play/pause button, and when I pause playback with the button, it doesn't redraw frames on seeking in paused state.

I've downloaded the GStreamer-Winbuild from here: http://www.gstreamer-winbuild.ylatuya.es/
Reply | Threaded
Open this post in threaded view
|

Re: How to make playbin to redraw frames on seek?

michael smith-6-3
On Tue, Dec 22, 2009 at 2:41 AM, wl2776 <[hidden email]> wrote:
>
>
> Julien Moutte-2 wrote:
>>
>> What video sink are you using ? It does not appear in your code sample.
>>
> Video sink was generated automatically.
> I've dumped an image using GST_DEBUG_BIN_TO_DOT_FILE, it appeared
> "videosink-actual-sink-dshowvideo".

dshowvideosink has a bug in this area. I was looking at it the other
week, but didn't get time to finish the fix before I went on holiday.

I should have a fix for it in early January.

Mike

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to make playbin to redraw frames on seek?

Andoni Morales
In reply to this post by wl2776
2009/12/22 wl2776 <[hidden email]>:

>
>
> Julien Moutte-2 wrote:
>>
>> What video sink are you using ? It does not appear in your code sample.
>>
> Video sink was generated automatically.
> I've dumped an image using GST_DEBUG_BIN_TO_DOT_FILE, it appeared
> "videosink-actual-sink-dshowvideo".
>
>
> Julien Moutte-2 wrote:
>>
>> You should not have to set the pipeline to PAUSED state after you issued
>> the
>> seek, but that can depend on the exact use case of your application
>> though.
>>
> This is a condition to my application, imposed by a client. The player has
> to pause playback when the slider is clicked.
> Anyway, this doesn't matter. The player also has a play/pause button, and
> when I pause playback with the button, it doesn't redraw frames on seeking
> in paused state.
I'm actually using the directdraw sink for that in longomatch (I need
it for framestepping), as it implements the XOverlay expose() method,
whilst the directshow one doesn't (I filled a bug for
that:https://bugzilla.gnome.org/show_bug.cgi?id=579926)
Anyway you should keep using the directshow sink instead of the
directdraw one for performance reasons. For your problem you can use a
hackish workarround to update frames while seeking which consist in
setting the pipeline to GST_STATE_PLAY before calling the seek
function and reset it to GST_STATE_PAUSE. It's a very ugly hack but
worked for me (don't blame me for the indentation, it's an old
revision ;)):
http://git.gnome.org/browse/longomatch/tree/libcesarplayer/src/bacon-video-widget-gst-0.10.c?id=18a08c71abca5d2f5ec194fb6f86196e0ddd68fc#n2302
Andoni

>
> I've downloaded the GStreamer-Winbuild from here:
> http://www.gstreamer-winbuild.ylatuya.es/
> --
> View this message in context: http://n4.nabble.com/How-to-make-playbin-to-redraw-frames-on-seek-tp976820p976860.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>



--
Andoni Morales Alastruey

LongoMatch:The Digital Coach
http://www.longomatch.ylatuya.es

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to make playbin to redraw frames on seek?

wl2776
Administrator
Andoni Morales wrote
I'm actually using the directdraw sink for that in longomatch (I need
it for framestepping), as it implements the XOverlay expose() method,
Thank you! It worked.
How did you manage to implement framestepping? Is your code open?
I have to implement this also.

I was looking at the GStreamer about 1 year ago, and the developers told me that they didn't implement frame accurate seeking for MPEG-2
Reply | Threaded
Open this post in threaded view
|

Re: How to make playbin to redraw frames on seek?

wl2776
Administrator
wl2776 wrote
I was looking at the GStreamer about 1 year ago, and the developers told me that they didn't implement frame accurate seeking for MPEG-2
I've found this: http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-framestep.txt
Wow! Great news! Will study...