Hi
I have to write a class that supports frame grabbing at a given time position in the video. Accessing the frames while in playing state is no problem, but the seeking functionality to jump to a certain video position seems to be quite a challenge. 1) I think the problem is that seeking only works when the main loop is already started ? Is that so? So I tried to use the seeking functionality for test purposes within registered callback functions, but that leaded to segmentation faults within the gstreamer library I could not resolve. I think I didn't use the seeking function at the proper place. Other code examples in the net used Qt or something similar and called the seeking function as response to an event produced by the GUI like a button click. 2) Where do I have to use the seeking functionality ? I haven't found yet any example code that uses seeking without the use of a GUI, that is written purely in C++. 3) Can anyone show me C++ example code using seeking without GUI support? 4) I use MPEG coded videos. Is it possible that this format doesn't support seeking? How can I check that in advance? My current gstreamer initialization looks like this: const void gstreamerWrapper::processVideo(std::string& strFileName, const void (*callback) (GstElement*, GstBuffer*, GstPad*, gpointer)) { gst_init(NULL, NULL); g_pLoop = g_main_loop_new(NULL, FALSE); pFlt = gst_element_factory_make("capsfilter", "flt"); g_object_set(G_OBJECT(pFlt), "caps", gst_caps_new_simple("video/x-raw-rgb", "width", G_TYPE_INT, 352, "height", G_TYPE_INT, 288, "bpp", G_TYPE_INT, 24, "depth", G_TYPE_INT, 24, NULL), NULL); pFakeAudioSink = gst_element_factory_make("fakesink", "fakeaudiosink"); pVideoSink = gst_element_factory_make("fakesink", "fakevideosink"); pPlay = gst_element_factory_make("playbin", "play"); g_object_set(G_OBJECT(pPlay), "uri", strFileName.c_str(), NULL); g_object_set(G_OBJECT(pPlay), "audio-sink", pFakeAudioSink, NULL); pIdentity = gst_element_factory_make("identity", "identity"); pBin = gst_bin_new("bin"); gst_bin_add_many(GST_BIN(pBin), pFlt, pIdentity, pVideoSink, NULL); gst_element_link_many(pFlt, pIdentity, pVideoSink, NULL); pPad = gst_element_get_static_pad(pFlt, "sink"); gst_element_add_pad(pBin, gst_ghost_pad_new("sink", pPad)); gst_object_unref(GST_OBJECT(pPad)); g_object_set(G_OBJECT(pPlay), "video-sink", pBin, NULL); g_object_set(G_OBJECT(pIdentity), "signal-handoffs", TRUE, NULL); g_signal_connect(pIdentity, "handoff", G_CALLBACK(callback), NULL); //<------ callback pBus = gst_pipeline_get_bus(GST_PIPELINE(pPlay)); gst_bus_add_watch(pBus, gstreamerWrapper::Wrapper_To_Call_bus_callback, NULL); gst_object_unref(pBus); g_pPlay = pPlay; g_timeout_add(200, (GSourceFunc) gstreamerWrapper::Wrapper_To_Call_cb_print_position, GST_PIPELINE(pPlay)); void* pt2Object; gstreamerWrapper obj; pt2Object = (void*) & obj; gst_element_set_state(pPlay, GST_STATE_PAUSED); g_main_loop_run(g_pLoop); gst_element_set_state(pPlay, GST_STATE_NULL); gst_object_unref(GST_OBJECT(pPlay)); g_pLoop = 0; g_pPlay = 0; } The gstreamerWrapper::Wrapper_To_Call_bus_callback function handles error and eof messages. "callback" is a pointer to the function that does some image processing. I try a long time now to get this "simple" functionality to get running. I would appreciate some help or advice that pushes me in the right direction. I just want a C++ class that is able to give me a frame at a certain time for a video. Thx in advance, Michael |
Free forum by Nabble | Edit this page |