[gst-devel] Playing avi - a newbie question

thiagoss thiagossantos at gmail.com
Sun Oct 12 16:09:06 CEST 2008


2008/10/12 Štěpán <stepan1117 at atlas.cz>

> Hi, I am really new to gstreamer and I am trying to play an .avi file
> (for a start). I am able to play the file with
>
> gst-launch  filesrc  location=something.avi  !  avidemux
> name=demuxer   demuxer.  !  queue ! ffdec_mpeg4 ! ffmpegcolorspace !
> sdlvideosink   demuxer. ! queue ! mad ! audioconvert ! audioresample !
> osssink
>
> But I need to do that in a program, so I tried to rewrite it to the
> code. Here is what I have now (argv[1] is the name of input .avi):
>
> ----------- code begins ------------
> GMainLoop *loop;
>
>    GstElement *pipeline, *source, *demuxer, *decoder,
> *conv,*mpeg_decoder,*mpeg_space,
>
>
> *video_sink,*audio_decoder,*audio_convert,*audio_resample,*audio_sink,*video_bin,
> *audio_bin,
>        *video_queue,*audio_queue;
>    GstBus *bus;
>
>    /* Initialisation */
>    gst_init(&argc, &argv);
>
>    loop = g_main_loop_new(NULL, FALSE);
>
>    /* Create gstreamer elements */
>    pipeline = gst_pipeline_new ("video-player");
>    source = gst_element_factory_make ("filesrc", "file-source"); //
> source
>    demuxer = gst_element_factory_make ("avidemux", "avi-demuxer"); //
> demuxer
>
>    video_queue = gst_element_factory_make("queue","video_queue"); //
> video fronta
>    mpeg_decoder = gst_element_factory_make ("ffdec_mpeg4",
> "mpeg-decoder"); // mpeg decoder
>    mpeg_space = gst_element_factory_make ("ffmpegcolorspace",
> "color-space"); // color space
>    video_sink = gst_element_factory_make("sdlvideosink",
> "video_sink"); // vykreslovac
>
>    audio_queue = gst_element_factory_make("queue","audio_queue");
>    audio_decoder = gst_element_factory_make ("mad", "audio-decoder");
>    audio_convert = gst_element_factory_make ("audioconvert",
> "audio-convert");
>    audio_resample = gst_element_factory_make("audioresample",
> "audio_resample");
>    audio_sink = gst_element_factory_make ("autoaudiosink", "audio-sink");
>
>    if (!pipeline || !source || !mpeg_decoder || !mpeg_space ||
> !video_sink || !audio_decoder
>            || !audio_convert || !audio_resample || !audio_sink ||
> !video_queue || !audio_queue){
>        g_printerr ("One element could not be created. Exiting.\n");
>        return -1;
>    }
>
>    /* we set the input filename to the source element */
>    g_object_set (G_OBJECT (source), "location", argv[1], NULL);
>
>    video_bin = gst_pipeline_new ("video_bin");
>    gst_bin_add_many (GST_BIN (video_bin),video_queue, mpeg_decoder,
> mpeg_space, video_sink, NULL);
>    gst_element_link_many (mpeg_decoder,
> video_queue,mpeg_space,video_sink, NULL);
>
>    audio_bin = gst_pipeline_new ("audio_bin");
>    gst_bin_add_many (GST_BIN (audio_bin), audio_queue,audio_decoder,
> audio_convert,audio_resample,audio_sink, NULL);
>    gst_element_link_many ( audio_decoder,
> audio_queue,audio_convert,audio_resample,audio_sink, NULL);
>
>    /* we add a message handler */
>    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,demuxer,NULL);
>    gst_element_link(source,demuxer);
>
>    gst_bin_add (GST_BIN (pipeline), video_bin);
>    gst_bin_add (GST_BIN (pipeline), audio_bin);
>
>    gst_element_link(demuxer,video_bin);
>    gst_element_link(demuxer,audio_bin);
>
>    /* Set the pipeline to "playing" state*/
>    g_print ("Now playing: %s\n", argv[1]);
>    gst_element_set_state (pipeline, GST_STATE_PLAYING);
>
>    /* Iterate */
>    g_print ("Running...\n");
>    g_main_loop_run (loop);
>
>    /* Out of the main loop, clean up nicely */
>    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));
> ----------- code ends --------------
>
> But this does not work, I always end with this error:
> gstavidemux.c(3779): gst_avi_demux_loop ():
> /GstPipeline:video-player/GstAviDemux:avi-demuxer:\nstreaming stopped,
> reason not-linked"
>
> Or, more precisely from the stderr:
>
> ---- log begins -----
> 0:00:16.645434576  [336m10637 [00m 0x7fa59c000b50  [37mLOG   [00m
>  [00;01;35m      GST_SCHEDULING
> gstpad.c:4069:gst_pad_push:<avi-demuxer:video_00> [00m pushing, but it
> was not linked
> 0:00:16.645442485  [336m10637 [00m 0x7fa59c000b50  [37mLOG   [00m
>  [00m            avidemux
> gstavidemux.c:3363:gst_avi_demux_combine_flows:<avi-demuxer> [00m
> cobined return not-linked
> 0:00:16.645450229  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00m            avidemux
> gstavidemux.c:3466:gst_avi_demux_process_next_entry:<avi-demuxer> [00m
> Processed buffer 3: not-linked
> 0:00:16.645458033  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00m            avidemux
> gstavidemux.c:3474:gst_avi_demux_process_next_entry:<avi-demuxer> [00m
> returning not-linked
> 0:00:16.645464954  [336m10637 [00m 0x7fa59c000b50  [32;01mINFO  [00m
>  [00m            avidemux gstavidemux.c:3736:gst_avi_demux_loop: [00m
> stream_movi flow: not-linked
> 0:00:16.645472746  [336m10637 [00m 0x7fa59c000b50  [37mLOG   [00m
>  [00m            avidemux
> gstavidemux.c:3752:gst_avi_demux_loop:<avi-demuxer> [00m pausing task,
> reason not-linked
> 0:00:16.645481639  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00;01;37;41m            GST_PADS
> gstpad.c:4768:gst_pad_pause_task:<avi-demuxer:sink> [00m pause task
> 0:00:16.645491405  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00m                task gsttask.c:476:gst_task_pause:<task2> [00m
> Pausing task 0x9c7940
> 0:00:16.645609511  [336m10637 [00m 0x7fa59c000b50  [33;01mWARN  [00m
>  [00m            avidemux
> gstavidemux.c:3779:gst_avi_demux_loop:<avi-demuxer> [00m error:
> Vnitřní chyba datového proudu.
> 0:00:16.645619223  [336m10637 [00m 0x7fa59c000b50  [33;01mWARN  [00m
>  [00m            avidemux
> gstavidemux.c:3779:gst_avi_demux_loop:<avi-demuxer> [00m error:
> streaming stopped, reason not-linked
> 0:00:16.645631090  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00;04m             default
> gstelement.c:1644:gst_element_message_full:<avi-demuxer> [00m start->1
> 0:00:16.645691274  [336m10637 [00m 0x7fa59c000b50  [32;01mINFO  [00m
>  [00;01;31;47m    GST_ERROR_SYSTEM
> gstelement.c:1675:gst_element_message_full:<avi-demuxer> [00m posting
> message: Vnitřní chyba datového proudu.
> 0:00:16.645704961  [336m10637 [00m 0x7fa59c000b50  [37mLOG   [00m
>  [00;01;37;41m         GST_MESSAGE
> gstmessage.c:204:gst_message_init: [00m new message 0x92f6c0
> 0:00:16.645713569  [336m10637 [00m 0x7fa59c000b50  [37mLOG   [00m
>  [00;01;37;41m         GST_MESSAGE
> gstmessage.c:289:gst_message_new_custom: [00m source avi-demuxer:
> creating new message 0x92f6c0 error
> 0:00:16.645740710  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00;43m             GST_BUS gstbus.c:337:gst_bus_post:<bus0> [00m
> [msg 0x92f6c0] posting on bus, type error, GstMessageError,
> gerror=(GstGError)(NULL), debug=(string)"gstavidemux.c\(3779\):\
> gst_avi_demux_loop\ \(\):\
> /GstPipeline:video-player/GstAviDemux:avi-demuxer:\012streaming\
> stopped\,\ reason\ not-linked"; from source <avi-demuxer>
> 0:00:16.645759690  [336m10637 [00m 0x7fa59c000b50  [36mDEBUG [00m
>  [00;01m                 bin
> gstbin.c:2729:gst_bin_handle_message_func:<video-player> [00m [msg
> 0x92f6c0] handling child avi-demuxer message of type error
> ---- log ends ------
>
> Linked against gstreamer v. 0.10.21-42.pm.2, gstreamer-plugins-good v.
> 0.10.7-38.1 on Opensuse 11 x86-64, 2.6.25.16-0.1-default
>
>
> There is definitely something, what I am doing wrong, but I am unable
> to find it...
>

You can't link the demuxer to your output bins like that. The demuxer uses
'sometimes' pads. Reading this you certainly help you:
http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/chapter-pads.html


>
> Thanks in advance
>
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>



-- 
Thiago Sousa Santos

Embedded Systems and Pervasive Computing Lab (Embedded)
Center of Electrical Engineering and Informatics (CEEI)
Federal University of Campina Grande (UFCG)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20081012/74d6ed71/attachment.htm>


More information about the gstreamer-devel mailing list