[gst-devel] Video freeze
Cai Yuanqing
yuanqing.cai at tieto.com
Thu Jan 6 02:36:43 CET 2011
On 01/06/2011 07:06 AM, sudarshan bisht wrote:
> I want to suggest you something. Instead of creating elements
> at the time of taking screenshot , why don't you create them already,
> add into bin and then link them later when you want to take screen
> shot. And obviously by this approach you save some time in taking
> screenshot.
>
> And try to use bin for set of elements, for example
> screenshot_bin having related elements and so on. This makes your code
> easy to read and debug.
I agree with sudarshan that you'd better make the screen shot related
elements into a Bin,and I guess that maybe some element can't change
state to PLAYING caused your "video freezen" problem.I have no idea what
happened in your case,you can enable the debug information and dig into it.
BTW,taking screen shot by pipeline usually need some time at least 100ms
IMHO :-)
Hope it helps.
> On Mon, Jan 3, 2011 at 9:57 AM, lithium <cmaster2 at hotmail.com
> <mailto:cmaster2 at hotmail.com>> wrote:
>
>
> I've been writing a tv capture program. Basically by the end of it
> i'm hoping
> to have the gstreamer stuff setup somewhat like this:
>
> /*
> /----queue----xvimagesink
> //screenoutput
> v4l2src---------tee-----
> \----queue----filesink //screenshot
> \----queue----\
> ----multiplexer
> ---filesink //recording
> /----queue----/
> alsasrc----------tee-----
> \----queue----alsasink //playback
> from capture if needed
> */
>
> At the moment i've implemented the top video branch and am now
> working on
> the screenshot one.
> I've been using a combination of gtk and gstreamer to write the
> program.
>
> When the program starts I call the 'openVideoPipeline' function
> (see below)
> and on clicking the screenshot button in my gtk window it runs the
> 'take_screenshot' function. The problem I am having is that when I
> press the
> screenshot button it causes the screen output to freeze. The file
> is not
> created by the filesink. I have found that when i click my button that
> causes the tv card options menu to be created and drawn it causes
> the screen
> output to resume playing and the file to be written. The only
> functions used
> from gstreamer in the tv card menu are 'gst_tuner_list_channels',
> 'gst_tuner_list_norms', and 'gst_tuner_get_norm'. It is very
> likely I am
> going about taking screenshots the wrong way, if someone has a
> better idea
> please suggest it. Otherwise it would be good if someone has any
> idea whats
> causing the video to freeze.
>
> I have tried setting the pipeline to playing again after unlinking the
> screenshot pads but it didn't change anything.
>
> int openVideoPipeline(videoIOStruct *videoIO)
> {
> //create elements
> videoIO->pipeline = gst_pipeline_new("tvVideo");
> videoIO->vidSrc = gst_element_factory_make("v4l2src",
> "source");
> GstElement *vidSink =
> gst_element_factory_make("xvimagesink", "sink");
> videoIO->tee = gst_element_factory_make("tee", "splitter");
> GstElement *vidQueue = gst_element_factory_make("queue", NULL);
>
> if (!videoIO->pipeline || !videoIO->vidSrc || !vidSink ||
> !videoIO->tee ||
> !vidQueue)
> return 0;
>
> //set arguments
> g_object_set(videoIO->vidSrc, "device", videoIO->devName,
> NULL);
>
> gst_bin_add_many(GST_BIN(videoIO->pipeline),
> videoIO->vidSrc, videoIO->tee,
> vidQueue, vidSink, NULL);
>
> videoIO->videoScreenPad =
> gst_element_get_request_pad(videoIO->tee,
> "src%d");
> GstPad *staticOutputPad =
> gst_element_get_static_pad(vidQueue, "sink");
>
> //link stuff
> gst_pad_link(videoIO->videoScreenPad, staticOutputPad);
>
> gst_object_unref(GST_OBJECT(videoIO->videoScreenPad));
>
> gst_element_link(videoIO->vidSrc, videoIO->tee);
>
> gst_element_link(vidQueue, vidSink);
>
> if (!videoIO->pipeline)
> return 0;
>
> return 1;
> }
>
> void close_screenshot(GstElement *jpegEncode, videoIOStruct *videoIO)
> {
> GstPad *pad1 = GST_PAD(g_object_get_data(G_OBJECT(jpegEncode),
> "videoScreenshotPad"));
> GstPad *pad2 = GST_PAD(g_object_get_data(G_OBJECT(jpegEncode),
> "staticOutputPad"));
> gst_pad_unlink(pad1, pad2);
> }
>
> void take_screenshot(GtkWidget *widget, videoIOStruct *videoIO)
> {
> GstElement *jpegOutput = gst_element_factory_make("filesink",
> "jpegoutput");
> GstElement *jpegQueue = gst_element_factory_make("queue",
> "jpgqueue");
> GstElement *jpegEncode = gst_element_factory_make("jpegenc",
> "jpegencoder");
>
> if (!jpegOutput || !jpegQueue || !jpegEncode ||
> !videoIO->jpegPipeline)
> return;
>
> //set arguments
> g_object_set(jpegOutput, "location", "test.jpg", NULL);
>
> //link stuff
> gst_bin_add_many(GST_BIN(videoIO->pipeline), jpegEncode,
> jpegQueue,
> jpegOutput, NULL);
>
> gst_element_link_many(jpegQueue, jpegEncode, jpegOutput, NULL);
>
> //gst_element_set_state(videoIO->jpegPipeline,
> GST_STATE_PLAYING);
>
> g_signal_connect(jpegEncode, "frame-encoded",
> G_CALLBACK(close_screenshot),
> videoIO);
>
> GstPad *videoScreenshotPad =
> gst_element_get_request_pad(videoIO->tee,
> "src%d");
> GstPad *staticOutputPad =
> gst_element_get_static_pad(jpegQueue, "sink");
> g_object_set_data(G_OBJECT(jpegEncode), "videoScreenshotPad",
> videoScreenshotPad);
> g_object_set_data(G_OBJECT(jpegEncode), "staticOutputPad",
> staticOutputPad);
>
> gst_pad_link(videoScreenshotPad, staticOutputPad);
> }
>
> --
> View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/Video-freeze-tp3171570p3171570.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> Learn how Oracle Real Application Clusters (RAC) One Node allows
> customers
> to consolidate database storage, standardize their database
> environment, and,
> should the need arise, upgrade to a full multi-node Oracle RAC
> database
> without downtime or disruption
> http://p.sf.net/sfu/oracle-sfdevnl
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> <mailto:gstreamer-devel at lists.sourceforge.net>
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>
>
>
> --
> Regards,
>
> Sudarshan Bisht
--
B.R
Cai Yuanqing
More information about the gstreamer-devel
mailing list