[gst-devel] Playing avi - a newbie question

Štěpán stepan1117 at atlas.cz
Sun Oct 12 15:21:08 CEST 2008


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 10637 0x7fa59c000b50 LOG  
      GST_SCHEDULING
gstpad.c:4069:gst_pad_push:<avi-demuxer:video_00> pushing, but it
was not linked
0:00:16.645442485 10637 0x7fa59c000b50 LOG  
            avidemux
gstavidemux.c:3363:gst_avi_demux_combine_flows:<avi-demuxer>
cobined return not-linked
0:00:16.645450229 10637 0x7fa59c000b50 DEBUG
            avidemux
gstavidemux.c:3466:gst_avi_demux_process_next_entry:<avi-demuxer>
Processed buffer 3: not-linked
0:00:16.645458033 10637 0x7fa59c000b50 DEBUG
            avidemux
gstavidemux.c:3474:gst_avi_demux_process_next_entry:<avi-demuxer>
returning not-linked
0:00:16.645464954 10637 0x7fa59c000b50 INFO 
            avidemux gstavidemux.c:3736:gst_avi_demux_loop:
stream_movi flow: not-linked
0:00:16.645472746 10637 0x7fa59c000b50 LOG  
            avidemux
gstavidemux.c:3752:gst_avi_demux_loop:<avi-demuxer> pausing task,
reason not-linked
0:00:16.645481639 10637 0x7fa59c000b50 DEBUG
            GST_PADS
gstpad.c:4768:gst_pad_pause_task:<avi-demuxer:sink> pause task
0:00:16.645491405 10637 0x7fa59c000b50 DEBUG
                task gsttask.c:476:gst_task_pause:<task2>
Pausing task 0x9c7940
0:00:16.645609511 10637 0x7fa59c000b50 WARN 
            avidemux
gstavidemux.c:3779:gst_avi_demux_loop:<avi-demuxer> error:
Vnitřní chyba datového proudu.
0:00:16.645619223 10637 0x7fa59c000b50 WARN 
            avidemux
gstavidemux.c:3779:gst_avi_demux_loop:<avi-demuxer> error:
streaming stopped, reason not-linked
0:00:16.645631090 10637 0x7fa59c000b50 DEBUG
             default
gstelement.c:1644:gst_element_message_full:<avi-demuxer> start->1
0:00:16.645691274 10637 0x7fa59c000b50 INFO 
    GST_ERROR_SYSTEM
gstelement.c:1675:gst_element_message_full:<avi-demuxer> posting
message: Vnitřní chyba datového proudu.
0:00:16.645704961 10637 0x7fa59c000b50 LOG  
         GST_MESSAGE
gstmessage.c:204:gst_message_init: new message 0x92f6c0
0:00:16.645713569 10637 0x7fa59c000b50 LOG  
         GST_MESSAGE
gstmessage.c:289:gst_message_new_custom: source avi-demuxer:
creating new message 0x92f6c0 error
0:00:16.645740710 10637 0x7fa59c000b50 DEBUG
             GST_BUS gstbus.c:337:gst_bus_post:<bus0>
[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 10637 0x7fa59c000b50 DEBUG
                 bin
gstbin.c:2729:gst_bin_handle_message_func:<video-player> [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...

Thanks in advance





More information about the gstreamer-devel mailing list