DVB Remux
Jan Schmidt
thaytan at noraisin.net
Fri Jan 30 06:10:53 PST 2015
On 30/01/15 23:52, Bernhard Graaf wrote:
Hi Bernhard,
In general for this kind of operation, you need a parser for each stream
before connecting to the muxer. i.e. h264parse, mpegvideoparse,
mpegaudioparse etc.
You'll need to do some autoplugging and find the right parsers, unless
you known which formats are in your DVB stream and can hard-code them.
- Jan.
> I’ve try to remux a mpegts-stream from satellite to a file with demuxing
> and muxing from/to a mpegts stream.
>
> I thought that this should be easy and build following simple C-Code:
>
> #include <stdio.h>
>
> #include <unistd.h>
>
> #include <string.h>
>
> #include <gst/gst.h>
>
> #include <glib.h>
>
> static gboolean
>
> bus_call (GstBus *bus,
>
> GstMessage *msg,
>
> gpointer data)
>
> {
>
> GMainLoop *loop = (GMainLoop *) data;
>
> 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);
>
> g_printerr ("Error: %s\n", error->message);
>
> g_error_free (error);
>
> g_main_loop_quit (loop);
>
> break;
>
> }
>
> /* case GST_MESSAGE_ELEMENT:
>
> {
>
> const GstStructure *str;
>
> str = gst_message_get_structure (msg);
>
> const gchar *name = gst_structure_get_name (str);
>
> printf("got message from %s\n", name);
>
> } */
>
> default:
>
> break;
>
> }
>
> return TRUE;
>
> }
>
> static void link_to_mux (GstPad *tolink_pad, GstElement *mux)
>
> {
>
> GstPad *pad;
>
> gchar *srcname, *sinkname;
>
> srcname = gst_pad_get_name (tolink_pad);
>
> pad = gst_element_get_compatible_pad (mux, tolink_pad, NULL);
>
> gst_pad_link (tolink_pad, pad);
>
> sinkname = gst_pad_get_name (pad);
>
> gst_object_unref (GST_OBJECT (pad));
>
> g_print ("A new pad %s was created and linked to %s\n", srcname,
> sinkname);
>
> g_free (sinkname);
>
> g_free (srcname);
>
> }
>
> static void
>
> on_pad_added (GstElement *element,
>
> GstPad *pad,
>
> gpointer data)
>
> {
>
> GstElement *mux = (GstElement *) data;
>
> GstCaps *caps;
>
> gchar *caps_string;
>
> gchar *name;
>
> name = gst_pad_get_name (pad);
>
> printf("A new pad %s was created\n", name);
>
> caps = gst_pad_query_caps (pad, NULL);
>
> caps_string = gst_caps_to_string (caps);
>
> g_print (" Capability: %s\n", caps_string);
>
> // if ((strstr(caps_string, "audio")) || (strstr(caps_string, "video")))
>
> link_to_mux(pad, mux);
>
> gst_caps_unref (caps);
>
> g_free (name);
>
> g_free (caps_string);
>
> }
>
> void no_more_pads (GstElement* object, gpointer user_data)
>
> {
>
> g_print("No more pads event from %s\n", gst_element_get_name(object));
>
> }
>
> int
>
> main ()
>
> {
>
> GMainLoop *loop;
>
> GstElement *pipeline, *source, *parse, *demux, *mux, *sink;
>
> GstBus *bus;
>
> gst_init (0, NULL);
>
> loop = g_main_loop_new (NULL, FALSE);
>
> pipeline = gst_pipeline_new ("DVB-Filesave");
>
> source = gst_element_factory_make ("dvbbasebin", "dvb-source");
>
> parse = gst_element_factory_make ("tsparse", "dvb-parse");
>
> demux = gst_element_factory_make ("tsdemux", "dvb-demux");
>
> mux = gst_element_factory_make ("mpegtsmux", "dvb-mux");
>
> sink = gst_element_factory_make ("filesink", "file-output");
>
> if (!pipeline || !source || !parse || !demux || !mux || !sink) {
>
> g_printerr ("One element could not be created. Exiting.\n");
>
> if(!pipeline) g_printerr("Pipeline not created\n");
>
> else if(!source) g_printerr("Source not created\n");
>
> else if(!sink) g_printerr("Sink not created\n");
>
> return -1;
>
> }
>
> g_object_set (G_OBJECT (source), "adapter", 2, NULL);
>
> g_object_set (G_OBJECT (source), "frequency", 12544000, NULL);
>
> g_object_set (G_OBJECT (source), "program-numbers", "17501", NULL);
>
> g_object_set (G_OBJECT (source), "polarity", "h", NULL);
>
> g_object_set (G_OBJECT (source), "symbol-rate", 22000, NULL);
>
> g_object_set (G_OBJECT (sink), "location", "remux_test.mpg", NULL);
>
> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>
> gst_bus_add_watch (bus, bus_call, loop);
>
> gst_object_unref (bus);
>
> gst_bin_add_many (GST_BIN (pipeline), source, parse, demux, mux, sink,
> NULL);
>
> gst_element_link_many (source, parse, demux, NULL);
>
> gst_element_link (mux, sink);
>
> g_signal_connect (demux, "pad-added", G_CALLBACK (on_pad_added), mux);
>
> g_signal_connect (demux, "no-more-pads", G_CALLBACK (on_pad_added),
> NULL);
>
> g_print ("Now playing: ");
>
> gst_element_set_state (pipeline, GST_STATE_PLAYING);
>
> g_print ("Running...\n");
>
> g_main_loop_run (loop);
>
> return 0;
>
> }
>
> But I get following error running with GST_DEBUG=5:
>
> <snipe>
>
> 0:00:01.482668761 5432 0x14c52d0 DEBUG task
> gsttask.c:663:gst_task_set_state:<dvbsrc0:src> Changing task 0x14ae290
> to state 2
>
> 0:00:01.482684269 5432 0x14c52d0 DEBUG GST_EVENT
> gstevent.c:301:gst_event_new_custom: creating new event 0x7fbca0003490
> eos 28174
>
> 0:00:01.482706379 5432 0x14c52d0 WARN basesrc
> gstbasesrc.c:2933:gst_base_src_loop:<dvbsrc0> error: Internal data flow
> error.
>
> 0:00:01.482720791 5432 0x14c52d0 WARN basesrc
> gstbasesrc.c:2933:gst_base_src_loop:<dvbsrc0> error: streaming task
> paused, reason not-negotiated (-4)
>
> 0:00:01.482736371 5432 0x14c52d0 DEBUG GST_MESSAGE
> gstelement.c:1804:gst_element_message_full:<dvbsrc0> start
>
> 0:00:01.482766019 5432 0x14c52d0 INFO GST_ERROR_SYSTEM
> gstelement.c:1835:gst_element_message_full:<dvbsrc0> posting message:
> Internal data flow error.
>
> 0:00:01.482797146 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:310:gst_bus_post:<bus2> [msg 0x7fbca80022c0] posting on bus
> error message: 0x7fbca80022c0, time 99:99:99.999999999, seq-num 149,
> element 'dvbsrc0', GstMessageError, gerror=(GError)NULL,
> debug=(string)"gstbasesrc.c\(2933\):\ gst_base_src_loop\ \(\):\
> /GstPipeline:DVB-Filesave/DvbBaseBin:dvb-source/GstDvbSrc:dvbsrc0:\012streaming\
> task\ paused\,\ reason\ not-negotiated\ \(-4\)";
>
> 0:00:01.482830109 5432 0x14c52d0 DEBUG bin
> gstbin.c:3409:gst_bin_handle_message_func:<dvb-source> [msg
> 0x7fbca80022c0] handling child dvbsrc0 message of type error
>
> 0:00:01.482846629 5432 0x14c52d0 DEBUG bin
> gstbin.c:3416:gst_bin_handle_message_func:<dvb-source> got ERROR
> message, unlocking state change
>
> 0:00:01.482860232 5432 0x14c52d0 DEBUG bin
> gstbin.c:3744:gst_bin_handle_message_func:<dvb-source> posting message
> upward
>
> 0:00:01.482873804 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:310:gst_bus_post:<bus0> [msg 0x7fbca80022c0] posting on bus
> error message: 0x7fbca80022c0, time 99:99:99.999999999, seq-num 149,
> element 'dvbsrc0', GstMessageError, gerror=(GError)NULL,
> debug=(string)"gstbasesrc.c\(2933\):\ gst_base_src_loop\ \(\):\
> /GstPipeline:DVB-Filesave/DvbBaseBin:dvb-source/GstDvbSrc:dvbsrc0:\012streaming\
> task\ paused\,\ reason\ not-negotiated\ \(-4\)";
>
> 0:00:01.482900244 5432 0x14c52d0 DEBUG bin
> gstbin.c:3409:gst_bin_handle_message_func:<DVB-Filesave> [msg
> 0x7fbca80022c0] handling child dvbsrc0 message of type error
>
> 0:00:01.482915307 5432 0x14c52d0 DEBUG bin
> gstbin.c:3416:gst_bin_handle_message_func:<DVB-Filesave> got ERROR
> message, unlocking state change
>
> 0:00:01.482928669 5432 0x14c52d0 DEBUG bin
> gstbin.c:3744:gst_bin_handle_message_func:<DVB-Filesave> posting message
> upward
>
> 0:00:01.482941762 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:310:gst_bus_post:<bus1> [msg 0x7fbca80022c0] posting on bus
> error message: 0x7fbca80022c0, time 99:99:99.999999999, seq-num 149,
> element 'dvbsrc0', GstMessageError, gerror=(GError)NULL,
> debug=(string)"gstbasesrc.c\(2933\):\ gst_base_src_loop\ \(\):\
> /GstPipeline:DVB-Filesave/DvbBaseBin:dvb-source/GstDvbSrc:dvbsrc0:\012streaming\
> task\ paused\,\ reason\ not-negotiated\ \(-4\)";
>
> 0:00:01.482965819 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:345:gst_bus_post:<bus1> [msg 0x7fbca80022c0] pushing on async queue
>
> 0:00:01.482985839 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:348:gst_bus_post:<bus1> [msg 0x7fbca80022c0] pushed on async queue
>
> 0:00:01.483001254 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:341:gst_bus_post:<bus0> [msg 0x7fbca80022c0] dropped
>
> 0:00:01.483001424 5432 0x13a0800 DEBUG GST_BUS
> gstbus.c:505:gst_bus_timed_pop_filtered:<bus1> got message
> 0x7fbca80022c0, error from dvbsrc0, type mask is 4294967295
>
> 0:00:01.483018949 5432 0x14c52d0 DEBUG GST_BUS
> gstbus.c:341:gst_bus_post:<bus2> [msg 0x7fbca80022c0] dropped
>
> 0:00:01.483073809 5432 0x14c52d0 INFO GST_ERROR_SYSTEM
> gstelement.c:1858:gst_element_message_full:<dvbsrc0> posted error
> message: Internal data flow error.
>
> 0:00:01.483039739 5432 0x13a0800 DEBUG GST_BUS
> gstbus.c:773:gst_bus_source_dispatch:<bus1> source 0x14dfe40 calling
> dispatch with error message: 0x7fbca80022c0, time 99:99:99.999999999,
> seq-num 149, element 'dvbsrc0', GstMessageError, gerror=(GError)NULL,
> debug=(string)"gstbasesrc.c\(2933\):\ gst_base_src_loop\ \(\):\
> /GstPipeline:DVB-Filesave/DvbBaseBin:dvb-source/GstDvbSrc:dvbsrc0:\012streaming\
> task\ paused\,\ reason\ not-negotiated\ \(-4\)";
>
> 0:00:01.483095819 5432 0x14c52d0 DEBUG GST_PADS
> gstpad.c:3498:check_sticky:<dvbsrc0:src> pushing all sticky events
>
> Error: Internal data flow error.
>
> 0:00:01.483145094 5432 0x14c52d0 DEBUG GST_PADS
> gstpad.c:3431:push_sticky:<dvbsrc0:src> event stream-start was already
> received
>
> 0:00:01.483165454 5432 0x13a0800 DEBUG GST_BUS
> gstbus.c:778:gst_bus_source_dispatch:<bus1> source 0x14dfe40 handler
> returns 1
>
> 0:00:01.483177839 5432 0x14c52d0 DEBUG GST_PADS
> gstpad.c:3431:push_sticky:<dvbsrc0:src> event caps was already received
>
> 0:00:01.483224132 5432 0x14c52d0 DEBUG GST_PADS
> gstpad.c:3431:push_sticky:<dvbsrc0:src> event segment was already received
>
> 0:00:01.483241264 5432 0x14c52d0 DEBUG GST_EVENT
> gstpad.c:5098:gst_pad_send_event_unchecked:<queue0:sink> have event type
> eos event: 0x7fbca0003490, time 99:99:99.999999999, seq-num 39, (NULL)
>
> Someone with any idea?
>
> Thanks a lot!
>
> 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