gstreamer stops playing the media content

Mo Cheng chengmo03013106 at gmail.com
Tue Sep 6 01:18:00 PDT 2011


first of all, you should used gst-launch in CMD to try if the pipeline woks
or not
if so, I guess there 's something problem with decoder
As I counter this kind of situation like freezing, There must have been
wrong with decoder, check it

On Mon, Aug 29, 2011 at 8:16 PM, akshat <akshatdewan at gmail.com> wrote:

> Hello,
> I am using gstreamerSDK(v0.10.6) on windowsXP. I am trying to play an .avi
> file but it stops playing the content within few seconds and does not play
> the file completely.
> I appreciate   your help.
>
> Thanks
> Akshat
>
> code
> ___________________________
> #include "stdafx.h"
> #include <windows.h>
> #include <iostream>
> #include &lt;gstreamer-0.10/gst/gst.h&gt;
> #include &lt;glib-2.0/glib.h&gt;
> #include "EmoStateDLL.h"
> #include "edk.h"
> #include "edkErrorCode.h"
> #include <time.h>
> #include <fstream>
> #include <map>
>
> #pragma comment(lib, "edk.lib")
> using namespace std;
>
>
> 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 = NULL;
>      GError *err = NULL;
>
>      gst_message_parse_error (msg, &err, &debug);
>
>      g_print ("Error: %s\n", err->message);
>      g_error_free (err);
>
>      if (debug) {
>        g_print ("Debug details: %s\n", debug);
>        g_free (debug);
>      }
>
>      g_main_loop_quit (loop);
>      break;
>    }
>    default:
>      break;
>  }
>
>  return TRUE;
> }
>
> static GstElement *pipeline,*filesrc, *avidemux, *hicon, *decodera,
>                          *audioconvert, *asink,
>                          *queuea, *queuev, *decoderv, *csc, *vscale,
> *vsink;
>
> static void on_decpad_added(GstElement *element, GstPad *pad )
> {
>    g_debug ("Signal: decoder pad-added");
>    GstCaps *caps;
>    GstStructure *str;
>
>    caps = gst_pad_get_caps (pad);
>    g_assert (caps != NULL);
>    str = gst_caps_get_structure (caps, 0);
>    g_assert (str != NULL);
>
>        g_debug ("Linking video pad to queue_vd");
>        // Link it actually
>        GstPad *targetsink = gst_element_get_pad (element == decodera ?
> queuea :
> queuev, "sink");
>        g_assert (targetsink != NULL);
>        gst_pad_link (pad, targetsink);
>
>        gst_object_unref (targetsink);
>    gst_caps_unref (caps);
> }
>
> static void on_pad_added (GstElement *element, GstPad *pad)
> {
>        g_debug ("Signal: demux pad-added");
>        GstCaps *caps;
>        GstStructure *str;
>
>        caps = gst_pad_get_caps (pad);
>        g_assert (caps != NULL);
>        str = gst_caps_get_structure (caps, 0);
>        g_assert (str != NULL);
>
>        const gchar *c = gst_structure_get_name(str);
>        if (g_strrstr (c, "video") || g_strrstr (c, "image")) {
>                g_debug ("Linking video pad to dec_vd");
>                // Link it actually
>                GstPad *targetsink = gst_element_get_pad (decoderv, "sink");
>                g_assert (targetsink != NULL);
>                gst_pad_link (pad, targetsink);
>                gst_object_unref (targetsink);
>        }
>
>        if (g_strrstr (c, "audio")) {
>                g_debug ("Linking audio pad to dec_ad");
>                // Link it actually
>                GstPad *targetsink = gst_element_get_pad (decodera, "sink");
>                g_assert (targetsink != NULL);
>                gst_pad_link (pad, targetsink);
>                gst_object_unref (targetsink);
>        }
>
>        gst_caps_unref (caps);
> }
>
> void g_ass(gboolean b)
> {
> /*      if(!b)g_debug("Error");
>        else g_debug("OK");*/
> }
>
> gint
> main (gint   argc,
>      gchar *argv[])
> {
>  GstStateChangeReturn ret;
>  GMainLoop *loop;
>  GstBus *bus;
>
>  /* initialization */
>  gst_init (&argc, &argv);
>  loop = g_main_loop_new (NULL, FALSE);
>
>  /*
>   * command line:
>   * gst-launch filesrc location=/home/neddens/r0013001.avi ! avidemux
> name=demux  demux.audio_00 ! decodebin ! queue ! audioconvert !
> audioresample ! autoaudiosink   demux.video_00 ! decodebin ! queue !
> ffmpegcolorspace ! videoscale ! autovideosink
>   *
> */
>
>
>  /* create elements */
>  pipeline = gst_pipeline_new ("pipeline0");
>
>  /* watch for messages on the pipeline's bus (note that this will only
>   * work like this when a GLib main loop is running) */
>  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
>  gst_bus_add_watch (bus, bus_call, loop);
>  gst_object_unref (bus);
>
>  filesrc  = gst_element_factory_make ("filesrc", "filesource");
>  avidemux = gst_element_factory_make ("avidemux", "dmux");
>  decodera = gst_element_factory_make ("decodebin2", "decoder0");
>  decoderv = gst_element_factory_make ("decodebin2", "decoder1");
>  vscale = gst_element_factory_make ("videoscale", "Scaler");
>
>  /* putting an audioconvert element here to convert the output of the
>   * decoder into a format that my_filter can handle (we are assuming it
>   * will handle any sample rate here though) */
>  audioconvert = gst_element_factory_make ("audioconvert", "audioconvert1");
>  queuea = gst_element_factory_make ("queue", "queue0");
>  queuev = gst_element_factory_make ("queue", "queue1");
>
>  /* there should always be audioconvert and audioresample elements before
>   * the audio sink, since the capabilities of the audio sink usually vary
>   * depending on the environment (output used, sound card, driver etc.) */
>  //audioresample = gst_element_factory_make ("audioresample",
> "audioresample0");
>  csc = gst_element_factory_make ("ffmpegcolorspace", "ffmpegcsp0");
>  vsink     = gst_element_factory_make ("autovideosink", "Video Renderer");
>  asink     = gst_element_factory_make ("autoaudiosink", "AudioSink");
>
>
>
>  g_object_set (G_OBJECT (filesrc), "location", "3.avi", NULL);
>
>  gst_bin_add_many (GST_BIN (pipeline), filesrc, avidemux, decodera,
>                  audioconvert, asink,csc,vscale,
>                  queuev, queuea, decoderv, vsink, NULL);
>
>
>  g_ass(gst_element_link (filesrc, avidemux));
>  g_ass(gst_element_link (queuev, csc));
>  g_ass(gst_element_link (csc, vscale));
>  g_ass(gst_element_link (vscale, vsink));
>
>  g_ass(gst_element_link (queuea, audioconvert));
>  g_ass(gst_element_link (audioconvert, asink));
>  // g_ass(gst_element_link (audioresample, asink));
>
>  g_signal_connect (avidemux, "pad-added", G_CALLBACK (on_pad_added), NULL);
>  //gst_element_set_state (decodera, GST_STATE_PLAYING);
>  //gst_element_set_state (decoderv, GST_STATE_PLAYING);
>  g_signal_connect (decodera, "new-decoded-pad", G_CALLBACK
> (on_decpad_added), decodera);
>  g_signal_connect (decoderv, "new-decoded-pad", G_CALLBACK
> (on_decpad_added), decoderv);
>
>  /* run */
>  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
>  if (ret == GST_STATE_CHANGE_FAILURE) {
>    GstMessage *msg;
>
>    g_print ("Failed to start up pipeline!\n");
>
>    /* check if there is an error message with details on the bus */
>    msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
>    if (msg) {
>      GError *err = NULL;
>
>      gst_message_parse_error (msg, &err, NULL);
>      g_print ("ERROR: %s\n", err->message);
>      g_error_free (err);
>      gst_message_unref (msg);
>    }
>    return -1;
>  }
>  GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS(GST_BIN(pipeline),
> GST_DEBUG_GRAPH_SHOW_ALL, "hi");
>  g_main_loop_run (loop);
>
>  /* clean up */
>  gst_element_set_state (pipeline, GST_STATE_NULL);
>  gst_object_unref (pipeline);
>
>  return 0;
> }
> ___________code end_________
>
> --
> View this message in context:
> http://gstreamer-devel.966125.n4.nabble.com/gstreamer-stops-playing-the-media-content-tp3776067p3776067.html
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110906/86b4906b/attachment.html>


More information about the gstreamer-devel mailing list