Unable to link rtspsrc and tee
Nicolas Dufresne
nicolas at ndufresne.ca
Sun Nov 17 19:14:47 UTC 2019
Le dimanche 17 novembre 2019 à 10:24 -0600, shyam a écrit :
> Hi Nicolas,
>
> I am very new to Gstreamer. I am trying to learn using
> examples available in the net. The use-case I want to implement requires
> display of live video streaming via RTSP and recording simultaneously in
> metroska (mkv) format.Any guidance in this will be of great help.I still
> need to get familiar with Gstreamer.
>
>
> I got this code from internet. This works fine with source being
> videotestsrc, but doesnot work with rtspsrc.
> int main(int argc, char *argv[])
> {
> /*******************************/
> if (!gst_debug_is_active()) {
> gst_debug_set_active(TRUE);
> GstDebugLevel dbglevel = gst_debug_get_default_threshold();
> if (dbglevel < GST_LEVEL_ERROR) {
> dbglevel = GST_LEVEL_ERROR;
> gst_debug_set_default_threshold(dbglevel);
> }
> }
> /*********************************/
> //signal(SIGINT, sigintHandler);
> gst_init(&argc, &argv);
>
> pipeline = gst_pipeline_new(NULL);
>
> src = gst_element_factory_make("rtspsrc", NULL);
> g_object_set(src, "location", "rtsp://location", NULL);
>
> tee = gst_element_factory_make("tee", "tee");
>
> encoder = gst_element_factory_make("x264enc", NULL);
> muxer = gst_element_factory_make("matroskamux", NULL);
> filesink = gst_element_factory_make("filesink", NULL);
> videoconvert = gst_element_factory_make("videoconvert", NULL);
> videosink = gst_element_factory_make("autovideosink", NULL);
> queue_display = gst_element_factory_make("queue", "queue_display");
> queue_record = gst_element_factory_make("queue", "queue_record");
>
> if (!pipeline || !src || !tee || !encoder || !muxer || !filesink ||
> !videoconvert || !videosink || !queue_record || !queue_display) {
> g_error("Failed to create elements");
> return -1;
> }
>
> g_object_set(filesink, "location", "rec.mkv", NULL);
> g_object_set(encoder, "tune", 4, NULL); /* important, the encoder usually
> takes 1-3 seconds to process this. Queue buffer is generally upto 1 second.
> Hence, set tune=zerolatency (0x4) */
>
> gst_bin_add_many(GST_BIN(pipeline), src, tee, queue_record, encoder, muxer,
> filesink, queue_display, videoconvert, videosink, NULL);
> if (!gst_element_link_many(src, tee, NULL)
> || !gst_element_link_many(tee, queue_record, encoder, muxer, filesink,
> NULL)
> || !gst_element_link_many(tee, queue_display, videoconvert, videosink,
> NULL)
> ) {
> g_error("Failed to link elements");
> return -2;
Normally things should fail here. rtspsrc have "sometimes" pad. See
[0] for more details. Another hint I'm giving you in advance, the
media-type coming out of rtspsrc is something like application/x-rtp,
while the videoconvert / encoder that you have after your tee wants
video/x-raw. Consider depayloading and decoding the stream first. As an
alternative, you may want to use uridecodebin instead of rtspsrc
directly.
[0] https://gstreamer.freedesktop.org/documentation/application-development/basics/pads.html?gi-language=c
> }
>
> 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("Starting loop");
> g_main_loop_run(loop);
>
> return 0;
> }
>
>
>
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
More information about the gstreamer-devel
mailing list