[gst-devel] Segfault when using callbacks in gst-python for buffer retrieval
Edward Hervey
bilboed at gmail.com
Fri Aug 29 15:18:17 CEST 2008
Hi,
Make your file begin as such:
=============
import gobject
gobject.threads_init()
import gst
...
=============
That should solve your issues
Edward
On Fri, 2008-08-29 at 15:01 +0200, Matthias Blaicher wrote:
> Hallo together,
>
> I'm working on a project which requires me to to buffer frames from a
> video4linux source in Python. I decided that gstreamer is perfectly
> fit for such a task and have already tried some initial code - Which
> all fail in a non spectacular segfault.
>
> Here is what I'm trying to do:
>
> I have such a path:
> v4lsrc ! video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace !
> pngenc snapshot=False ! fakesink name=sink
>
> Which should generate a continuous stream of png frames. Now i try to
> intercept the exchanged Buffer objects by using the handoff event of
> fakesink with a callback. But whenever I activate the callback, the
> python interpreter dies with a segmentation fault. I also tried to
> intercept the Buffers with the Pad.add_buffer_probe call, but that
> fails the same way.
>
> My code is:
>
> import gst
> import time
>
> gst.debug_set_active(True)
> gst.debug_set_default_threshold(4)
>
>
> def callback(fakesink, buffer, pad, data=None):
> return True
>
>
> def probe_callback_fakesrc(pad, buffer):
> return True
>
> #v4lsrc
> pipeline = gst.parse_launch('videotestsrc !
> video/x-raw-yuv,width=640,height=480 ! ffmpegcolorspace ! pngenc
> snapshot=False ! fakesink name=sink')
> fakesink = pipeline.get_by_name('sink')
>
> # Way 1
> fakesink.props.signal_handoffs = True
> fakesink.connect("handoff", callback)
>
> ## Way 2
> #pad = fakesink.get_pad('sink')
> #pad.add_buffer_probe(probe_callback_fakesrc)
>
> pipeline.set_state(gst.STATE_PLAYING)
>
> while True:
> #Sleep so that context switching for gst works
> time.sleep(1)
>
>
>
> Which fails such as (with debug leve 4 and strace)
>
> 0:00:04.553704144 9029 0x832f1d8 INFO GST_STATES
> gstelement.c:2148:gst_element_continue_state:<sink> completed state
> change to PLAYING
> 0:00:04.553717205 9029 0x832f1d8 INFO GST_STATES
> gstelement.c:2161:gst_element_continue_state:<sink> posting
> state-changed PAUSED to PLAYING
> 0:00:04.553714760 9029 0x8325750 DEBUG basesink
> gstbasesink.c:1508:gst_base_sink_wait_preroll:<sink> continue after
> preroll
> 0:00:04.553743117 9029 0x8325750 DEBUG basesink
> gstbasesink.c:1678:gst_base_sink_do_sync:<sink> possibly waiting for
> clock to reach 0:00:00.000000000
> 0:00:04.553763652 9029 0x8325750 DEBUG basesink
> gstbasesink.c:1468:gst_base_sink_wait_clock:<sink> sync disabled
> 0:00:04.553784466 9029 0x8325750 DEBUG basesink
> gstbasesink.c:1684:gst_base_sink_do_sync:<sink> clock returned 4
> 0:00:04.553798993 9029 0x8325750 DEBUG basesink
> gstbasesink.c:2029:gst_base_sink_render_object:<sink> rendering buffer
> 0x8328e68
> 0:00:04.553789634 9029 0x832f1d8 DEBUG GST_BUS
> gstbus.c:337:gst_bus_post:<bus0> [msg 0x83321d0] posting on bus, type
> state-changed, GstMessageState, old-state=(GstState)GST_STATE_PAUSED,
> new-state=(GstState)GST_STATE_PLAYING,
> pending-state=(GstState)GST_STATE_VOID_PENDING; from source <sink>
> 0:00:04.553835034 9029 0x832f1d8 DEBUG bin
> gstbin.c:2719:gst_bin_handle_message_func:<pipeline0> [msg 0x83321d0]
> handling child sink message of type state-changed
> 0:00:04.553848933 9029 0x832f1d8 DEBUG bin
> gstbin.c:2923:gst_bin_handle_message_func:<pipeline0> posting message
> upward
> 0:00:04.553862133 9029 0x832f1d8 DEBUG GST_BUS
> gstbus.c:337:gst_bus_post:<bus1> [msg 0x83321d0] posting on bus, type
> state-changed, GstMessageState, old-state=(GstState)GST_STATE_PAUSED,
> new-state=(GstState)GST_STATE_PLAYING,
> pending-state=(GstState)GST_STATE_VOID_PENDING; from source <sink>
> 0:00:04.553889303 9029 0x832f1d8 DEBUG GST_BUS
> gstbus.c:367:gst_bus_post:<bus1> [msg 0x83321d0] pushing on async
> queue
> 0:00:04.553887906 9029 0x8325750 DEBUG pygst
> pygstminiobject.c:152:pygstminiobject_new: have to create wrapper for
> object 0x8328e68
> 0:00:04.553904041 9029 0x832f1d8 DEBUG GST_BUS
> gstbus.c:372:gst_bus_post:<bus1> [msg 0x83321d0] pushed on async queue
> 0:00:04.553913679 9029 0x8325750 DEBUG pygst
> pygstminiobject.c:171:pygstminiobject_new: created Python object
> 0xb7ddc800 for GstMiniObject 0x8328e68 [ref:4]
> 0:00:04.553917870 9029 0x832f1d8 DEBUG GST_BUS
> gstbus.c:363:gst_bus_post:<bus0> [msg 0x83321d0] dropped
> 0:00:04.553937357 9029 0x832f1d8 DEBUG GST_STATES
> gstelement.c:2380:gst_element_set_state_func:<sink> returned SUCCESS
> ) = ? ERESTARTNOHAND (To be restarted)
> +++ killed by SIGSEGV +++
> Process 9029 detached
>
> I use Ubuntu Hardy with gst.version() == (0, 10, 18, 0)
>
> Does anybody know what I'm doing wrong here?
>
> Sincerely,
>
> Matthias Blaicher
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list