Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:00:40+00:00 2026-06-12T22:00:40+00:00

I have a small C project which uses GStreamer. I want to load a

  • 0

I have a small C project which uses GStreamer. I want to load a video and display it together with a subtitle (textoverlay) and elapsed time (timeoverlay).

My idea looks like this:

- create a textoverlay and set a sample subtitle
- create a timeoverlay
- create a videosink
- put the three elements in a new bin and link them: 
  textoverlay -> timeoverlay -> videosink
- use playbin2 for playback and send the video from playbin2 to the new bin 

Here is my testing standalone application:

// Save as "test.c". Compile with: 
// gcc -o test `pkg-config --cflags --libs gtk+-2.0 gstreamer-0.10 gstreamer-interfaces-0.10` test.c
#include <gst/gst.h>
#include <gtk/gtk.h>

int main(int argc, char **argv) {
    // Init - GTK is only used here as a GUI hook
    gtk_init (&argc, &argv);
    gst_init(0, NULL);

    // Path to file - juts a simple demo file
    char uri[2048];
    sprintf(&uri[0], "file:///tmp/1.mpg");

    // Playbin and URI
    GstElement *playbin2 = gst_element_factory_make ("playbin2", "playbin2");
    g_object_set (G_OBJECT (playbin2), "uri", &uri[0], NULL);

    // Elements - videosink, textoverlay, timeoverlay
    GstElement *videosink = gst_element_factory_make ("sdlvideosink", "videosink");
    GstElement *textoverlay = gst_element_factory_make("textoverlay", "textoverlay");
    GstElement *timeoverlay = gst_element_factory_make("timeoverlay", "timeoverlay");

    // Set sample text in textoverlay
    g_object_set(G_OBJECT(textoverlay), "text", "Test Subtitle", NULL);

    // Create bin, add elements
    GstElement *mybin = gst_bin_new("mybin");
    gst_bin_add (GST_BIN (mybin), videosink);
    gst_bin_add (GST_BIN (mybin), textoverlay);
    gst_bin_add (GST_BIN (mybin), timeoverlay);

    // Get sink pad for textoverlay and make it a ghostpad for bin
    GstPad *pad_textoverlay_sink = gst_element_get_pad(textoverlay, "video_sink");
    gst_element_add_pad(mybin, gst_ghost_pad_new("sink", pad_textoverlay_sink));

    // Link elements: textoverlay -> timeoverlay -> videosink
    gst_element_link_pads(textoverlay, "src", timeoverlay, "sink");
    gst_element_link_pads(timeoverlay, "src", videosink, "sink");

    // Conect the bin to the playbin
    g_object_set (G_OBJECT (playbin2), "video-sink", mybin, NULL);

    // Play video
    gst_element_set_state (playbin2, GST_STATE_PLAYING);

    // GTK Main loop
    gtk_main ();
}

If I link the src pad of textoverlay to the sink pad of the videosink (thus skipping timeoverlay), I get a video and a subtitle – just as expected.

If I change the code and make the sink pad of timeoverlay a ghostpad for mybin, then link the src pad of timeoverlay to videosink (thus skipping textoverlay) – I get a video with elapsed time, just as expected.

However, when I try to cascade textoverlay and timeoverlay, there’s no video. It does not depend on videosink – same with xvimagesink and ximagesink. No error is shown. With gstreamer-launch it works fine, so obviously I’m doing something wrong in C – I just can’t figure out what.

Any help will be appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:00:42+00:00Added an answer on June 12, 2026 at 10:00 pm

    What solves the problem is using a pipeline instead of bin.

    GstElement *mybin = gst_pipeline_new ("my-pipeline");
    

    Why it does, however, is still unclear to me. GStreamer docs say that pipeline is just a top-level bin; I found no restriction in the docs on how many elements can reside in a bin or on what can they do. On the other hand, playbin2 is internally a pipeline, therefore mybin can be a regular bin (and it works fine as a regular bin as long as only textoverlay or timeoverlay is used).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small Qt4 project which I want to build with cmake. It
I have an AS3 project. Which uses say 100 swfs, these are very small
I've got a Java project, which uses a small SQLite database. Now I want
I have done a small project, which consists of 5 excel sheet in, code
I'm developing a small POS for a university project. I have a form which
I have some small project to stream video to android device. Streaming is done
I am new user of Sonar. I have a small project in java which
I have a small project I am working on which is WPF c# that
I have a small project on git, on which I am the sole developer.
I have a small project that I want to deploy to both Heroku and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.