Muxing video and subtitile using matroska mux

surendra rgouthami409 at gmail.com
Wed Jul 9 20:46:54 PDT 2014


Hi,

I am trying to MUX the video from RTSP source and subtitile data from the
appsrc.

When i run the pipe lines individually (i.e only with appsrc or rtspsrc ) 
then the data is written in to the MKV file.

If i try to mux both video and subtitle(Code is given below) then the
data(Both video and subtitle)  or not written in to the MKV file.

Can some one help me to solve the issue.

How to mux subtitle and video data using matroskamux?

#include <gst/gst.h>
static GMainLoop *loop;

static void
cb_need_data(GstElement *appsrc,
	      guint       unused_size,
	      gpointer    user_data)
{
  static gboolean white = FALSE;
  static GstClockTime timestamp = 0;
  GstBuffer *buffer;
  guint size;
  GstFlowReturn ret;

  size = 10 * 2;

  buffer = gst_buffer_new_allocate (NULL, size, NULL);

  /* this makes the image black/white */
  gst_buffer_memset (buffer, 0, white ? 0xAA : 0x55, size);

  white = !white;

  GST_BUFFER_PTS (buffer) = timestamp;
  GST_BUFFER_DURATION (buffer) = gst_util_uint64_scale_int (1, GST_SECOND,
2);

  timestamp += GST_BUFFER_DURATION (buffer);

  g_signal_emit_by_name (appsrc, "push-buffer", buffer, &ret);

  if (ret != GST_FLOW_OK) {
    /* something wrong, stop pushing */
    g_main_loop_quit (loop);
  }
}

static void on_pad_added (GstElement *element, GstPad *pad, gpointer data)
{

   GstPad *sinkpad;
   GstElement *decoder = (GstElement *) data;
   /* We can now link this pad with the rtsp-decoder sink pad */
   g_print ("Dynamic pad created, linking source/demuxer\n");

   sinkpad = gst_element_get_static_pad (decoder, "sink");
   gst_pad_link (pad, sinkpad);
   gst_object_unref (sinkpad);
}

gint
main (gint   argc,
      gchar *argv[])
{
  GstElement *pipeline, *appsrc,*rtspsrc,*queue1;

  /* init GStreamer */
  gst_init (&argc, &argv);

  pipeline = gst_parse_launch("rtspsrc name= src
location=rtsp://root:axis@10.33.14.3:554/axis-media/media.amp ! queue
name=queue1 ! rtph264depay ! h264parse ! matroskamux name=mux ! filesink
location=test.mkv ! appsrc name=src1 ! text/x-raw, format=(string)utf8 !
mux", NULL);

  loop = g_main_loop_new (NULL, FALSE);

  appsrc = gst_bin_get_by_name(GST_BIN (pipeline),"src1");
  rtspsrc = gst_bin_get_by_name(GST_BIN (pipeline),"src");
  queue1  = gst_bin_get_by_name(GST_BIN (pipeline),"queue1");

  g_object_set(G_OBJECT(appsrc), "is-live", TRUE, "do-timestamp",
TRUE,"min-latency",0, NULL);

  /* setup appsrc */
  g_object_set (G_OBJECT (appsrc),"stream-type", 0,"format",
GST_FORMAT_TIME, NULL);

  //g_timeout_add_seconds ((guint)(60), (GSourceFunc)timeout_cb, appsrc);
  g_signal_connect (appsrc, "need-data", G_CALLBACK (cb_need_data), NULL);

  if(! g_signal_connect (rtspsrc, "pad-added", G_CALLBACK
(on_pad_added),queue1))
   {
            g_warning ("Linking part (A) with part (B) Fail...");
   }


  /* play */
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (loop);

  /* clean up */
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (GST_OBJECT (pipeline));
  g_main_loop_unref (loop);

  return 0;
  }




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Muxing-video-and-subtitile-using-matroska-mux-tp4667884.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list