[gst-devel] play wma file error

Edward Hervey bilboed at gmail.com
Tue Sep 11 09:16:36 CEST 2007


Hi,

  Don't use ffdemux_asf but asfdemux.

On 9/11/07, xiaofeng xu <kilyxu at gmail.com> wrote:
>
>
> Hi
> I try to use ffmpeg plugin to play wma music file and it works. See my code.
>
> But at the end of stream, it gives a error message: internal data stream
> error.
>
> I don't know why. Can you help me? Thank you!
>
>
> gcc -Wall `pkg-config --cflags --libs gstreamer-0.10` player.c -o player
>
> #include <gst/gst.h>
>
> GstElement *pipeline, *source, *parser, *decoder, *conv, *sink;
>
> static gboolean bus_call (GstBus *bus, GstMessage *msg, gpointer data)
> {
>   GMainLoop *loop = 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 *err;
>
>       gst_message_parse_error (msg, &err, &debug);
>       g_free (debug);
>
>       g_print ("Error: %s\n", err->message);
>       g_error_free (err);
>
>       g_main_loop_quit (loop);
>       break;
>     }
>     default:
>       break;
>   }
>
>   return TRUE;
> }
>
> static void new_pad (GstElement *element, GstPad *pad, gpointer data)
> {
>   GstPad *sinkpad;
>   g_print ("Dynamic pad created, linking parser/decoder\n");
>
>   sinkpad = gst_element_get_pad (decoder, "sink");
>   gst_pad_link (pad, sinkpad);
>
>   gst_object_unref (sinkpad);
> }
>
> int main (int   argc, char *argv[])
> {
>   GMainLoop *loop;
>   GstBus *bus;
>
>   /* initialize GStreamer */
>   gst_init (&argc, &argv);
>   loop = g_main_loop_new (NULL, FALSE);
>
>   /* check input arguments */
>   if (argc != 2) {
>     g_print ("Usage: %s <wma filename>\n", argv[0]);
>     return -1;
>   }
>
>   /* create elements */
>   pipeline = gst_pipeline_new ("audio-player");
>   source = gst_element_factory_make ("filesrc", "file-source");
>   parser = gst_element_factory_make ("ffdemux_asf", "asf-parser");
>   decoder = gst_element_factory_make ("ffdec_wmav2", "wmav2-decoder");
>   conv = gst_element_factory_make ("audioconvert", "converter");
>   sink = gst_element_factory_make ("alsasink", "alsa-output");
>   if (!pipeline || !source || !parser || !decoder || !conv || !sink) {
>     g_print ("One element could not be created\n");
>     return -1;
>   }
>
>   g_object_set (G_OBJECT (source), "location", argv[1], 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, parser, decoder, conv, sink, NULL);
>
>   gst_element_link (source, parser);
>   gst_element_link_many (decoder, conv, sink, NULL);
>   g_signal_connect (parser, "pad-added", G_CALLBACK (new_pad), NULL);
>
>   g_print ("Setting to PLAYING\n");
>   gst_element_set_state (pipeline, GST_STATE_PLAYING);
>   g_print ("Running\n");
>   g_main_loop_run (loop);
>
>   g_print ("Returned, stopping playback\n");
>   gst_element_set_state (pipeline, GST_STATE_NULL);
>   g_print ("Deleting pipeline\n");
>   gst_object_unref (GST_OBJECT (pipeline));
>
>   return 0;
> }
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2005.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>


-- 
Edward Hervey
Multimedia editing developer
http://www.pitivi.org/




More information about the gstreamer-devel mailing list