TS-File not seekable

Krzysztof Konopko krzysztof.konopko at youview.com
Fri Nov 30 01:37:53 PST 2012


Hi Bernhard,

What do you mean by "different results" and "problem with seeking"?
Could you be more specific? Does your program produce non empty file?

Why do you need tsparse if you writing to a file? Are you going to
handle some messages from tsparse?

In the first instance you don't have to force EOS in your app. Just stop
your program on the command line by pressing Ctrl+C and the default
signal handler will do the job. You can improve it later.

You can learn more about your program behaviour if you set GST_DEBUG
variable when running it, e. g.:

GST_DEBUG=4 ./your-app

See gst-launch-1.0 manual to learn more about debugging levels.

I'd recommend making your app simpler so you can evolve it later. Use
gst_parse_launch() instead of gst_element_factory_make(). Less code,
less oportunity to make a mistake and you can always refer to any
element in the pipe by its name (use 'name' property):

GError *error;
GstElement *dvb_pipe = gst_parse_launch ("dvbbasebin name=dvb"
                                         " ! queue ! tsparse "
                                         " ! filesink qos=TRUE",
                                         &error);

if (!dvb_pipe) {
  g_printerr ("Failed to create the pipeline: %s\n",
              error ? error->message : "(unknown error)");
    return FALSE;
}

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);

Return gboolean instead of int unless you have a good reason to return int.

You can use g_object_set() to set multiple properties:
dvb_source   = gst_bin_get_by_name (GST_BIN (dvb_pipe), "dvb");

g_object_set (G_OBJECT (dvb_source),
              "adapter", atoi(argv[3]),
              "frontend", atoi(argv[6]),
              "frequency", atoi(freq),
              "program_numbers", argv[7],
              "polarity", argv[9],
              "symbol-rate", atoi(argv[5]),
              NULL);

Cheers,
Kris

On 30/11/12 08:03, Bernhard Graaf wrote:
> I've made some test to finish the pipe:
> 
> Direct call of 'g_main_loop_quit (loop)' ore parsing message with
> 'gst_element_send_event (dvb_pipe, gst_event_new_eos())' and handle the
> loop_quit in the message loop function, but all with the same result.
> 
> My question is now: Where is the different between gst-launch and my own
> program in the ts-file results? What do gst-launch more then I do?
> 
>  
> 
> If someone could help me, I will be very happy!
> 
>  
> 
> Thanks a lot
> 
> Bernhard
> 
>  
> 
>  
> 
> ---------------------------------------------------------------------
> 
>  
> 
> Hi @ all,
> 
>  
> 
> I've an issue with my own program using dvbbasebin:
> 
> The pipe: gst-launch-1.0 dvbbasebin adapter=1 frequency=12544000
> program-numbers="17501" polarity="h" symbol-rate=22000 ! queue ! tsparse !
> filesink location=test_ts.mpg
> 
> Results a file that has no problem with seeking
> 
> But my own program:
> 
>  
> 
>  
> 
> **************************************************************************
> 
> #include <stdio.h>
> 
> #include <unistd.h>
> 
> #include <sys/types.h>
> 
> #include <sys/stat.h>
> 
> #include <fcntl.h>
> 
> #include <stdlib.h>
> 
> #include <string.h>
> 
> #include <errno.h>
> 
> #include <gst/gst.h>
> 
> #include <glib.h>
> 
> #include <syslog.h>
> 
> #include <sys/time.h>
> 
> #include <sys/select.h>
> 
>  
> 
>  
> 
> GstElement *dvb_pipe, *dvb_source,  *dvb_sink, *dvb_queue, *dvb_parse;
> 
> GstBus *dvb_bus;
> 
> GMainLoop *loop;
> 
>  
> 
> static gboolean
> 
> dvb_bus_call (GstBus     *tmp_bus,
> 
>           GstMessage *msg,
> 
>           gpointer    data)
> 
> {
> 
>  
> 
>   char tmp_str[254];
> 
>  
> 
>   switch (GST_MESSAGE_TYPE (msg)) {
> 
>  
> 
>     case GST_MESSAGE_EOS:
> 
>       g_print ("End of stream\n");
> 
>       g_main_loop_quit (loop);
> 
>       break;
> 
>  
> 
>     case GST_MESSAGE_ERROR: {
> 
>       gchar  *debug;
> 
>       GError *error;
> 
>  
> 
>       gst_message_parse_error (msg, &error, &debug);
> 
>       g_free (debug);
> 
>  
> 
>       sprintf(tmp_str, "Error: %s\n", error->message);
> 
>       g_printerr ("%s\n", tmp_str);
> 
>       syslog(LOG_ERR, "%s\n",tmp_str);
> 
>       g_error_free (error);
> 
>       g_main_loop_quit (loop);
> 
>  
> 
>       break;
> 
>     }
> 
>     default:
> 
>       break;
> 
>   }
> 
>  
> 
>   return TRUE;
> 
> }
> 
>  
> 
>  
> 
> int init_gst_tv()
> 
> {
> 
>  
> 
>   gst_init (0, NULL);
> 
>  
> 
>   dvb_pipe = gst_pipeline_new ("DVB-Streamer");
> 
>   dvb_source   = gst_element_factory_make ("dvbbasebin", "dvb-source");
> 
>   dvb_queue     = gst_element_factory_make ("queue",      "dvb-queue");
> 
>   dvb_parse     = gst_element_factory_make ("tsparse",    "dvb-parse");
> 
>   dvb_sink     = gst_element_factory_make ("filesink",   "dvb-sink");
> 
>  
> 
>  
> 
>   if (!dvb_pipe || !dvb_source || !dvb_queue || !dvb_parse || !dvb_sink) 
> 
>   {
> 
>     g_printerr ("One element could not be created. Exiting.\n");
> 
>     syslog(LOG_ERR, "Ein Pipe-Element nicht erstellt -->
> Programmabbruch\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_queue) g_printerr("DVB-Queue not created\n");
> 
>     else if(!dvb_parse) g_printerr("DVB-Parse not created\n");
> 
>     else if(!dvb_sink) g_printerr("DVB-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_queue, dvb_parse,
> dvb_sink, NULL);
> 
>   gst_element_link_many (dvb_source, dvb_queue, dvb_parse, dvb_sink, NULL);
> 
>  
> 
>   g_object_set (G_OBJECT (dvb_sink),    "qos",           TRUE, NULL);  
> 
>  
> 
>   return 1;
> 
> }
> 
>  
> 
> int main (int argc, char **argv)
> 
> {
> 
>  
> 
>  
> 
>   char tmp_str[254], freq[40], file_name[254], rec_pids[25];
> 
>   char np_name[254];
> 
>   int pid = 0;
> 
>   int fd;
> 
>  
> 
>   sprintf(freq,"%s000", argv[4]);
> 
>   sprintf(file_name, "test.mpg");
> 
>  
> 
>   loop = g_main_loop_new (NULL, FALSE);
> 
>  
> 
>   init_gst_tv();
> 
>  
> 
>   g_object_set (G_OBJECT (dvb_source), "adapter", atoi(argv[3]), NULL);
> 
>   g_object_set (G_OBJECT (dvb_source), "frontend", atoi(argv[6]), NULL); 
> 
>   g_object_set (G_OBJECT (dvb_source), "frequency", atoi(freq), NULL);
> 
>   g_object_set (G_OBJECT (dvb_source), "program_numbers", argv[7], NULL);
> 
>   g_object_set (G_OBJECT (dvb_source), "polarity", argv[9], NULL);
> 
>   g_object_set (G_OBJECT (dvb_source), "symbol-rate", atoi(argv[5]), NULL);
> 
>   g_object_set (G_OBJECT (dvb_sink), "location", file_name, NULL);
> 
>  
> 
>  
> 
>   gst_element_set_state (dvb_pipe, GST_STATE_PLAYING);
> 
>  
> 
>   g_print ("Running...\n");
> 
>   g_main_loop_run (loop);
> 
>  
> 
>   gst_element_set_state (dvb_pipe, GST_STATE_NULL);
> 
>  
> 
>   g_print ("Deleting pipeline\n");
> 
>   gst_object_unref (GST_OBJECT (dvb_pipe));
> 
>  
> 
> return 1;
> 
> }
> 
> ****************************************************************************
> *
> 
>  
> 
> Is the result not seekable!
> 
>  
> 
> Something missing to generate a seekable ts-file?
> 
>  
> 
> Thanks a lot and sorry for this long mail!
> 
> Bernhard
> 
> 
> 
> 
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
> 



More information about the gstreamer-devel mailing list