[gst-devel] Video freeze

lithium cmaster2 at hotmail.com
Mon Jan 3 05:27:33 CET 2011


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.




More information about the gstreamer-devel mailing list