AW: Converting MPEG-TS to MPEG-PS

Bernhard Graaf bernhard.graaf at
Thu Jun 16 07:48:57 PDT 2011

Hi Kapil,


thanks' for your answer and your help. The following pipe is running well
(after your mail):

gst-launch-0.10 -vvv dvbsrc adapter=1 frequency=12544000 pids=97:511:512:515
polarity='h' symbol-rate=22000 ! mpegtsdemux name=demux demux.video_01ff !
queue ! mpegpsmux name=mux ! filesink
location=/home/bgraaf/Share/TVAufnahmen/Test3.mpg demux.audio_0200 ! queue !


But the next problem I have is that this pipe should run in my own


#include <stdio.h>

#include <unistd.h>

#include <gst/gst.h>

#include <glib.h>

#include <string.h>


GstElement *dvb_pipe, *dvb_source, *dvb_demux, *dvb_queue, *dvb_mux,
*dvb_sink, *fake_queue, *fake_sink;

GstBus *dvb_bus;

GMainLoop *loop;

int mux_pad = 0;


static gboolean

dvb_bus_call (GstBus     *tmp_bus,

          GstMessage *msg,

          gpointer    data)



  switch (GST_MESSAGE_TYPE (msg)) {



      g_print ("End of stream\n");




      gchar  *debug;

      GError *error;


      gst_message_parse_error (msg, &error, &debug);

      g_free (debug);


      g_printerr ("Error: %s\n", error->message);

      g_error_free (error);








  return TRUE;



static void

tv_demux_pad_added (GstElement *element,

              GstPad     *pad,

              gpointer    data)


  GstPad *sinkpad;

  GstElement *queue = (GstElement *) data;

  gchar *name;

  char tmp_str[20];


  name = gst_pad_get_name (pad);

  g_print ("A new pad %s was created\n", name);


  if(strncmp(name,"v",1) == 0) || (strncmp(name,"a",1) == 0))


    sprintf(tmp_str,"pad%d", mux_pad);

    printf("Pad: %s\n", tmp_str);

    sinkpad = gst_element_get_static_pad (queue, tmp_str);

    gst_pad_link (pad, sinkpad);

    gst_object_unref (sinkpad);

    g_print ("Dynamic pad created, linking TS-Demuxer/TS-Muxer\n");





    sinkpad = gst_element_get_static_pad (fake_queue, "sink");

    gst_pad_link (pad, sinkpad);

    gst_object_unref (sinkpad);

    g_print ("Dynamic pad created, linking TS-Demuxer/Fake-Sink\n");


  g_free (name);




static void

tv_mux_pad_added (GstElement *element,

              GstPad     *pad,

              gpointer    data)


  GstPad *sinkpad;

  GstElement *queue = (GstElement *) data;

  gchar *name;


  name = gst_pad_get_name (pad);

  g_print ("A new pad %s was created\n", name);


  sinkpad = gst_element_get_static_pad (queue, "sink");

  gst_pad_link (pad, sinkpad);

  gst_object_unref (sinkpad);

  g_print ("Dynamic pad created, linking TS-Muxer/Video-Sink\n");


  g_free (name);





int init_gst()


  gst_init (0, NULL);

  loop = g_main_loop_new (NULL, FALSE);


  dvb_pipe = gst_pipeline_new ("DVB-Streamer");

  dvb_source      = gst_element_factory_make ("dvbsrc",      "dvb-source");

  dvb_demux       = gst_element_factory_make ("mpegtsdemux", "dvb-demux");

  dvb_queue = gst_element_factory_make ("queue",       "dvb-queue");

  dvb_mux         = gst_element_factory_make ("mpegpsmux",   "dvb-mux");

  dvb_sink        = gst_element_factory_make ("filesink",    "dvb-sink");

  fake_queue      = gst_element_factory_make ("queue",       "fake-queue");

  fake_sink = gst_element_factory_make ("fakesink",    "fake-sink");


  if (!dvb_pipe || !dvb_source || !dvb_demux || !dvb_queue || !dvb_mux ||
!dvb_sink || !fake_queue || !fake_sink) 


    g_printerr ("One element could not be created. Exiting.\n");

    if(!dvb_pipe) g_printerr("DVB-Pipeline not created\n");

    else if(!dvb_source) g_printerr("DVB-Source not created\n");

    else if(!dvb_demux) g_printerr("DVB-Demuxer not created\n");

    else if(!dvb_queue) g_printerr("DVB-Queue not created\n");

    else if(!dvb_mux) g_printerr("DVB-Muxer not created\n");

    else if(!dvb_sink) g_printerr("DVB-Sink not created\n");

    else if(!fake_queue) g_printerr("Fake-Queue not created\n");

    else if(!fake_sink) g_printerr("Fake-Sink not created\n");

    return -1;



  dvb_bus = gst_pipeline_get_bus (GST_PIPELINE (dvb_pipe));

  gst_bus_add_watch (dvb_bus, dvb_bus_call, NULL);

  gst_object_unref (dvb_bus);


  gst_bin_add_many (GST_BIN (dvb_pipe), dvb_source, dvb_demux, dvb_queue,
dvb_mux, dvb_sink, fake_queue, fake_sink, NULL);

  gst_element_link (dvb_source, dvb_demux);

  gst_element_link_many(dvb_queue, dvb_mux, dvb_sink, NULL);

  gst_element_link_many(fake_queue, fake_sink, NULL);


  g_signal_connect (dvb_demux, "pad-added", G_CALLBACK (tv_demux_pad_added),

  g_signal_connect (dvb_mux, "pad-added", G_CALLBACK (tv_mux_pad_added),


  return 1;



int send_p7()


  gst_element_set_state (dvb_pipe, GST_STATE_NULL); 


  g_object_set (G_OBJECT (dvb_source), "adapter", 1, NULL);

  g_object_set (G_OBJECT (dvb_source), "frequency", 12544000, NULL);

  g_object_set (G_OBJECT (dvb_source), "pids", "97:511:512:515", NULL);

  g_object_set (G_OBJECT (dvb_source), "polarity", "h", NULL);

  g_object_set (G_OBJECT (dvb_source), "symbol-rate", 22000, NULL);

  g_object_set (G_OBJECT (dvb_sink), "location",
"/home/bgraaf/Videos/Test.mpg", NULL);


  g_print ("Now playing: Prog 7\n");

  gst_element_set_state (dvb_pipe, GST_STATE_PLAYING);

  g_print ("Running...\n");

  g_main_loop_run (loop);

  return 0;






main (int argc, char *argv[])





  return 0;





The messages from the program are:

A new pad video_01ff was created


(<unknown>:2469): GStreamer-CRITICAL **: gst_pad_link: assertion `GST_IS_PAD
(sinkpad)' failed


(<unknown>:2469): GStreamer-CRITICAL **: gst_object_unref: assertion `object
!= NULL' failed


So it look like a link problem between the mpegtsdemux-src-pads and the
mpegpsmux-sink-pads. What's wrong with this program.


Thanks' a lot for your help!!!





Von: at
[ at]
Im Auftrag von Kapil Agrawal
Gesendet: Dienstag, 14. Juni 2011 08:18
An: Discussion of the development of and with GStreamer
Betreff: Re: Converting MPEG-TS to MPEG-PS


Your pipe may look like

gst-launch dvbsrc ! mpegtsdemux name=demux demux.video_0040 ! queue !
mpegpsmux name=mux ! filesink demux.audio_0040 ! queue ! mux.

So in your pipe only video pad of demux was linked with video pad of mux.
You need to link both audio & video.


On Fri, Jun 10, 2011 at 3:17 PM, Bernhard Graaf <bernhard.graaf at>



Sorry, there is a fault in my pipe. I try this:

gst-launch-0.10 -v dvbsrc adapter=0 frequency=12544000 pids=97:511:512:515
polarity='h' symbol-rate=22000 ! mpegtsdemux es-pids=511:512 ! mpegpsmux !
filesink location=test.mpg


The Messages are:


New clock: MpegTSClock

/GstPipeline:pipeline0/GstMpegTSDemux:mpegtsdemux0.GstPad:sink: caps =
video/mpegts, mpegversion=(int)2, systemstream=(boolean)true

/GstPipeline:pipeline0/GstMpegTSDemux:mpegtsdemux0: pat-info =
((GValueArray*) 0x8307b60)

/GstPipeline:pipeline0/GstMpegTSDemux:mpegtsdemux0: pmt-info =
((MpegTsPmtInfo*) 0xb6c04680)

/GstPipeline:pipeline0/MpegPsMux:mpegpsmux0.GstPad:pad0: caps = video/mpeg,
mpegversion=(int)2, systemstream=(boolean)false

/GstPipeline:pipeline0/MpegPsMux:mpegpsmux0.GstPad:src: caps = video/mpeg,
mpegversion=(int)2, systemstream=(boolean)true

/GstPipeline:pipeline0/GstFileSink:filesink0.GstPad:sink: caps = video/mpeg,
mpegversion=(int)2, systemstream=(boolean)true


And that's what I get: Only the video-stream without any audio.


What's wrong with this pipe?


Thanks' a lot!



Von: at
<mailto:gstreamer-devel-bounces%2Bbernhard.graaf> at] Im Auftrag von Bernhard Graaf
Gesendet: Freitag, 10. Juni 2011 10:28
An: 'Discussion of the development of and with GStreamer'
Betreff: Converting MPEG-TS to MPEG-PS




I have a problem for seeking in MPEG-TS-files (to slow) and want to convert
a TS-Stream to PS.

But it seems to be a little tricky to select the pids. My pipe looks like

'gst-launch-0.10 dvbsrc pids=97:511:512 frequ... ! mpegtsdemux
es-pids=511:512 !  mpeg2dec ! filesink location=test.mpg'


The pids are: 97 = PMT, 511 = Video, 512 = Audio.


But it doesn't work. The file is always 0 Bytes long.


Without converting, it's a very simple pipe:

'gst-launch-0.10 dvbsrc pids=97:511:512 frequ... ! filesink


And it's works very good.


What to I wrong to convert the stream?


Thanks' a lot for helping!!




gstreamer-devel mailing list
gstreamer-devel at

-- (Gstreamer, ffmpeg, Red5, Streaming)
twitter handle: @gst_kaps

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gstreamer-devel mailing list