Tool/software: Linux
Why i'm Getting this Type of Errors
Pipeline Initialized Successfully...
All the Elements were Created.....
Tee was Enabled...
(stream_record:5644): GLib-GObject-WARNING **: value "((GstQueueLeaky) 134518788)" of type `GstQueueLeaky' is invalid or out of range for property `leaky' of type `GstQueueLeaky'
Text Was Added...
Filesink was Linked...
RTMP Sink Was Linked...
(stream_record:5644): GStreamer-WARNING **: Name 'queue1' is not unique in bin 'pipeline0', not adding
(stream_record:5644): GStreamer-WARNING **: Name 'videoconvert0' is not unique in bin 'pipeline0', not adding
(stream_record:5644): GStreamer-WARNING **: Name 'queue0' is not unique in bin 'pipeline0', not adding
(stream_record:5644): GStreamer-WARNING **: Name 'x264enc0' is not unique in bin 'pipeline0', not adding
Checking...
** (stream_record:5644): ERROR **:
Failed to link elements
Trace/breakpoint trap (core dumped)
For this Code :-
/******************************************************************************
* Header File
******************************************************************************/
#include <string.h>
#include <gst/gst.h>
#include <signal.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
/**********************************************************************
* Macro Substitutions
***********************************************************************/
/**********************************************************************
* Global variable declerations
***********************************************************************/
static GMainLoop *loop;
static GstElement *pipeline, *v4src, *filter, *tee, *queue, *queue1, *timelay, *textlay, *convert, *filemux, *filesink, *encoder, *muxer, *sink, *new_element;
static GstCaps *filtercaps = NULL;
static GstBus *bus;
/***********************************************************************
* Function Prototypes
************************************************************************/
int sigintHandler(int unused);
static gboolean message_cb (GstBus * bus, GstMessage * message, gpointer user_data);
/**********************************************************************
* Function : main function
*
* Description : handle the Plugins and record the video
*
* Parameters : void
*
* Return value: it will send the Interrupt to Signal handler.
***********************************************************************/
int main(int argc, char* argv)
{
signal(SIGINT,sigintHandler);
gst_init ( NULL, NULL);
printf("\n\n\tPipeline Initialized Successfully...\n");
pipeline = gst_pipeline_new(NULL);
v4src = gst_element_factory_make("videotestsrc", NULL);
filter = gst_element_factory_make("capsfilter", NULL);
tee = gst_element_factory_make("tee", NULL);
convert = gst_element_factory_make("videoconvert", NULL);
queue = gst_element_factory_make("queue", NULL);
queue1 = gst_element_factory_make("queue", NULL);
timelay = gst_element_factory_make("timeoverlay", NULL);
textlay = gst_element_factory_make("textoverlay", NULL);
encoder = gst_element_factory_make("x264enc", NULL);
filemux = gst_element_factory_make("mp4mux", NULL);
muxer = gst_element_factory_make("flvmux", NULL);
filesink = gst_element_factory_make("filesink", NULL);
sink = gst_element_factory_make("rtmpsink", NULL);
/**********************************************************************************************************************************************
gst-launch-1.0 -e videotestsrc pattern=ball is-live=true ! timeoverlay ! textoverlay text="@Fossilshale" ! 'video/x-raw,width=1280,height=720,framerate=30/1' ! tee name=liveTee ! queue leaky=downstream ! videoconvert! queue ! x264enc ! avimux ! filesink location=output02.mp4 liveTee. ! queue leaky=downstream ! videoconvert ! queue ! x264enc ! flvmux ! queue ! rtmpsink location='rtmp://52.39.19.115:1935/live/camera1000'
**********************************************************************************************************************************************/
if (pipeline == NULL || v4src == NULL || filter == NULL || tee == NULL || convert == NULL || encoder == NULL || queue == NULL || timelay == NULL || textlay == NULL || queue1 == NULL || filemux == NULL || filesink == NULL || muxer == NULL || sink == NULL)
{
g_error("\n\tFailed to create elements\n");
return -1;
}
filtercaps = gst_caps_new_simple ("video/x-raw",
"framerate",GST_TYPE_FRACTION,25,1,
"width", G_TYPE_INT,1280,
"height", G_TYPE_INT,720,
NULL );
g_object_set (G_OBJECT (filter), "caps", filtercaps, NULL);
gst_caps_unref (filtercaps ) ;
printf("\n\tAll the Elements were Created.....\n");
/*g_object_set(v4src, "device", "/dev/video0", NULL);
printf("\n\tSource Was Linked...\n");*/
g_object_set(tee, "name", "liveTee", NULL);
printf("\n\tTee was Enabled... \n");
g_object_set(queue1, "leaky", "downstream", NULL);
g_object_set(textlay, "text", "@Fossilshale", NULL);
printf("\n\tText Was Added...\n");
g_object_set(filesink, "location", "test00.mp4", NULL);
printf("\n\tFilesink was Linked...\n");
g_object_set(sink, "location", "rtmp://64.62.151.174:1935/live/camera1000", NULL);
printf("\n\t RTMP Sink Was Linked...\n");
/**********************************************************************************************************************************************
gst-launch-1.0 -e videotestsrc pattern=ball is-live=true ! timeoverlay ! textoverlay text="@Fossilshale" ! 'video/x-raw,width=1280,height=720,framerate=30/1' ! tee name=liveTee ! queue leaky=downstream ! videoconvert! queue ! x264enc ! avimux ! filesink location=output02.mp4 liveTee. ! queue leaky=downstream ! videoconvert ! queue ! x264enc ! flvmux ! queue ! rtmpsink location='rtmp://52.39.19.115:1935/live/camera1000'
**********************************************************************************************************************************************/
gst_bin_add_many(GST_BIN(pipeline), v4src, timelay, textlay, filter, tee,queue1, convert, queue, encoder, filemux, filesink, queue1, convert, queue, encoder, muxer, sink, NULL);
printf("\n\tChecking...\n");
if (!gst_element_link_many(v4src, timelay, textlay, filter, tee, NULL) || !gst_element_link_many(tee, queue1, convert, encoder, filemux, filesink, NULL) || !gst_element_link_many(tee, convert, queue, encoder, muxer, queue, sink, NULL))
{
g_error("\n\tFailed to link elements\n");
return -2;
}
loop = g_main_loop_new(NULL, FALSE);
bus = gst_pipeline_get_bus(GST_PIPELINE (pipeline));
gst_bus_add_signal_watch(bus);
g_signal_connect(G_OBJECT(bus), "message", G_CALLBACK(message_cb), NULL);
gst_object_unref(GST_OBJECT(bus));
gst_element_set_state(pipeline, GST_STATE_PLAYING);
g_print("\n\tStarting loop...\n");
g_main_loop_run(loop);
return 0;
}
/**********************************************************************
* Function : Signal Handler Function
*
* Description : It will get the Interrup signal and Send EOS to the Gstreamer.
*
* Parameters : unused signals
*
* Return value: it will send Eos only
***********************************************************************/
int sigintHandler(int unused)
{
g_print("\n\tSending EoS\n");
gst_element_send_event(pipeline, gst_event_new_eos());
return 0;
}
/**********************************************************************
* Function : Message Callback finction
*
* Description : It will handle all the messages from the bus
*
* Parameters : bus, message and the user data
*
* Return value: it will determine the End of encode.
***********************************************************************/
static gboolean message_cb (GstBus * bus, GstMessage * message, gpointer user_data)
{
switch (GST_MESSAGE_TYPE (message))
{
case GST_MESSAGE_ERROR:
{
GError *err = NULL;
gchar *name, *debug = NULL;
name = gst_object_get_path_string (message->src);
gst_message_parse_error (message, &err, &debug);
g_printerr ("ERROR: from element %s: %s\n", name, err->message);
if (debug != NULL)
g_printerr ("Additional debug info:\n%s\n", debug);
g_error_free (err);
g_free (debug);
g_free (name);
g_main_loop_quit (loop);
break;
}
case GST_MESSAGE_WARNING:
{
GError *err = NULL;
gchar *name, *debug = NULL;
name = gst_object_get_path_string (message->src);
gst_message_parse_warning (message, &err, &debug);
g_printerr ("ERROR: from element %s: %s\n", name, err->message);
if (debug != NULL)
g_printerr ("Additional debug info:\n%s\n", debug);
g_error_free (err);
g_free (debug);
g_free (name);
break;
}
case GST_MESSAGE_EOS:
{
g_print ("\n\tGot EOS\n");
g_main_loop_quit (loop);
gst_element_set_state (pipeline, GST_STATE_NULL);
g_main_loop_unref (loop);
gst_object_unref (pipeline);
g_print("\n\tStream terminatted Succesfully\n\n");
exit(0);
break;
}
default:
break;
}
return TRUE;
}