<div dir="ltr"><div><div>Hi Olivier,<br><br></div>I have written video recorder in a C code for audio and video recording into mpg file using matroskamux. I can record video successfully but I can't get GST_MESSAGE_EOS for end of streaming on bus.<br>
</div><div><br>C code for recorder : <br>#include <gst/gst.h><br><br>static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)<br>{<br> GMainLoop *loop = (GMainLoop *) data;<br> switch (GST_MESSAGE_TYPE (msg)) {<br>
case GST_MESSAGE_EOS:<br> g_print ("End of stream\n");<br> g_main_loop_quit (loop);<br> break;<br> case GST_MESSAGE_ERROR:{<br> gchar *debug;<br> GError *error;<br>
gst_message_parse_error (msg, &error, &debug);<br> g_free (debug);<br> g_printerr ("Error: %s\n", error->message);<br> g_error_free (error);<br> g_main_loop_quit (loop);<br>
break;<br> }<br> default:<br> break;<br> }<br> return TRUE;<br> }<br><br><br> int main (int argc, char *argv[])<br> {<br> GMainLoop *loop;<br> GstElement *pipeline, *vsource, *vcapsfilter, *h263rtpdepay, *h263dec, *queue1;<br>
GstElement *asource, *acapsfilter, *pcmurtpdepay, *mulawdec, *queue2;<br> GstElement *mux, *sink;<br> GstBus *bus;<br> guint bus_watch_id;<br> GstCaps *caps;<br><br> /* Initialisation */<br> gst_init (&argc, &argv);<br>
loop = g_main_loop_new (NULL, FALSE);<br><br> /* Check input arguments */<br> if (argc != 2) {<br> g_printerr ("Usage: %s <MPG filename\n", argv[0]);<br> return -1;<br> }<br> /* Create gstreamer elements */<br>
pipeline = gst_pipeline_new ("av-recorder");<br> vsource = gst_element_factory_make ("udpsrc", "vid-source");<br> vcapsfilter = gst_element_factory_make ("capsfilter", "vid-caps");<br>
h263rtpdepay = gst_element_factory_make ("rtph263pdepay", "vrtpdepay");<br> h263dec = gst_element_factory_make ("avdec_h263", "vdecoder");<br> queue1 = gst_element_factory_make ("queue", "queue1");<br>
asource = gst_element_factory_make ("udpsrc", "aud-source");<br> acapsfilter = gst_element_factory_make ("capsfilter", "audio-caps");<br> pcmurtpdepay = gst_element_factory_make ("rtppcmudepay", "artpdepay");<br>
mulawdec = gst_element_factory_make ("mulawdec", "adecoder");<br> queue2 = gst_element_factory_make ("queue", "queue2");<br> mux = gst_element_factory_make ("matroskamux", "avmux");<br>
sink = gst_element_factory_make ("filesink", "file-output");<br><br> if (!pipeline || !vsource || !vcapsfilter || !h263rtpdepay || !h263dec || !queue1 ||<br> !asource || !acapsfilter || !pcmurtpdepay || !mulawdec || !queue2 || !mux ||<br>
!sink) {<br> g_printerr ("One element could not be created. Exiting.\n");<br> return -1;<br> }<br><br> g_object_set (G_OBJECT (vsource), "port", 9078, NULL);<br> g_object_set (G_OBJECT (asource), "port", 3333, NULL);<br>
g_object_set (G_OBJECT (sink), "location", argv[1], NULL);<br> <br> caps =gst_caps_from_string("application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998,payload=(int)96");<br>
g_object_set (G_OBJECT (vcapsfilter), "caps", caps, NULL);<br> gst_caps_unref (caps);<br><br> caps = gst_caps_from_string("application/x-rtp,encoding-name=PCMU,payload=0,clock-rate=8000");<br>
g_object_set (G_OBJECT (acapsfilter), "caps", caps, NULL);<br> gst_caps_unref (caps);<br><br> bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));<br> bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);<br>
gst_object_unref (bus);<br><br> gst_bin_add_many (GST_BIN (pipeline),<br> vsource, vcapsfilter, h263rtpdepay, h263dec, queue1,<br> asource, acapsfilter, pcmurtpdepay, mulawdec, queue2,<br>
mux, sink, NULL);<br><br> gst_element_link_many (vsource, vcapsfilter,h263rtpdepay,h263dec, queue1, mux, NULL);<br> gst_element_link_many (asource, acapsfilter, pcmurtpdepay, mulawdec, queue2, mux, NULL);<br>
gst_element_link_many (mux, sink, NULL);<br><br> gst_element_set_state (pipeline, GST_STATE_PLAYING);<br><br> g_print ("Recording (or not!)...\n");<br> g_main_loop_run (loop);<br> g_print ("Returned, stopping recording\n");<br>
gst_element_set_state (pipeline, GST_STATE_NULL);<br><br> g_print ("Deleting pipeline\n");<br> gst_object_unref (GST_OBJECT (pipeline));<br> g_source_remove (bus_watch_id);<br> g_main_loop_unref (loop);<br>
<br> return 0;<br> }<br><br></div><div><br></div>I am streaming the rtp audio and video to the recorder using command :<br>gst-launch-1.0 -v uridecodebin uri=<url.mpg> name=demux demux. ! queue ! autovideoconvert ! avenc_h263p ! rtph263ppay ! udpsink host=127.0.0.1 port=9078 demux. ! queue ! audioconvert ! audioresample ! mulawenc ! rtppcmupay ! udpsink host=127.0.0.1 port=3333<br>
<br>I am getting EOS message successfully from above command but not getting the End of Stream messege. <br><br>Please find attached recorder file same as code given above with the mail if you need. <br>Any help/pointer appericiated ...<br>
<br><div><div><br><div><div dir="ltr"><div><font><span style="font-family:arial,helvetica,sans-serif"><font>Thanks ,<br>Amar</font><br><u><span style="color:rgb(0,0,255)"></span></u></span></font></div></div>
</div></div></div></div>