vaapidecode could not be created

Gofrane gofrane at gmail.com
Tue May 5 03:27:51 PDT 2015


Hello,

I have tried to write this pipeline ( it work well ) with C code  
*
gst-launch-1.0 filesrc location= Simpsons.mp4 ! qtdemux ! vaapidecode !
vaapisink*

but I have gotten this problem * " vaapidecode could not  be created."*

#include <gst/gst.h>
   
/* Handler for the pad-added signal */
static void on_pad_added(GstElement* element,GstPad* pad,gpointer* data)
{
  GstPad* sinkpad;
  GstElement * decoder = (GstElement*)data;
  GstCaps* caps;
  GstStructure* str;
  gchar* tex;

  caps = gst_pad_get_caps(pad);
  str = gst_caps_get_structure(caps,0);
  tex = (gchar*)gst_structure_get_name(str);

  if(g_strrstr(tex,"video"))
  {
    sinkpad = gst_element_get_static_pad(decoder,"sink");
    gst_pad_link(pad,sinkpad);
    gst_object_unref(sinkpad);
  }

}
   
int main(int argc, char *argv[]) {
 GstElement *pipeline, *source, *vaapisink,*vaapidecode,*demux;
  GstBus *bus;
  GstMessage *msg;
  GstStateChangeReturn ret;
  gboolean terminate = FALSE;
   
  /* Initialize GStreamer */
  gst_init (&argc, &argv);
    
  /* Create the elements */
  source =gst_element_factory_make ("filesrc", "source");
 if ( !source) {
    g_printerr (" source could not  be created.\n");
    return -1;
  }  
   demux= gst_element_factory_make("qtdemux ", "demux");
 if ( !vaapisink) {
    g_printerr (" demux could not  be created.\n");
    return -1;
  }  
 vaapidecode= gst_element_factory_make("vaapidecode","decoder"); 
  if ( !vaapidecode) {
    g_printerr (" vaapidecode could not  be created.\n");
    return -1;
  }  
  vaapisink= gst_element_factory_make ("vaapisink", "sink");
  if ( !vaapisink) {
    g_printerr (" vaapisink could not  be created.\n");
    return -1;
  }  


  /* Create the empty pipeline */
pipeline = gst_pipeline_new ("test-pipeline");

  
   /* pads 
 gst_element_link_pads (source, "source", demux, "demux"); */

  /* Build the pipeline. Note that we are NOT linking the source at this
   * point. We will do it later. */
 gst_bin_add_many (GST_BIN (pipeline), source,demux,vaapidecode ,vaapisink,
NULL);

if (gst_element_link(source,demux )!= TRUE)g_printerr ("Elements 1 could not
be linked.\n");
 
if (gst_element_link (vaapidecode, vaapisink) != TRUE) g_printerr ("Elements
2 could not be linked.\n");


/* Modify the source's properties */
  g_object_set (G_OBJECT (source), "location",
"big_buck_bunny_1080p_h264.mov ", NULL);

   
  /* Connect to the pad-added signal */
 g_signal_connect(demux,"pad-added",G_CALLBACK(on_pad_added),vaapidecode);
   
  /* Start playing */
  ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
  if (ret == GST_STATE_CHANGE_FAILURE) {
    g_printerr ("Unable to set the pipeline to the playing state.\n");
    gst_object_unref (pipeline);
    return -1;
  }
   
  /* Listen to the bus */
  bus = gst_element_get_bus (pipeline);
  do {
    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
        GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
   
    /* Parse message */
    if (msg != NULL) {
      GError *err;
      gchar *debug_info;
       
      switch (GST_MESSAGE_TYPE (msg)) {
        case GST_MESSAGE_ERROR:
          gst_message_parse_error (msg, &err, &debug_info);
          g_printerr ("Error received from element %s: %s\n",
GST_OBJECT_NAME (msg->src), err->message);
          g_printerr ("Debugging information: %s\n", debug_info ? debug_info
: "none");
          g_clear_error (&err);
          g_free (debug_info);
          terminate = TRUE;
          break;
        case GST_MESSAGE_EOS:
          g_print ("End-Of-Stream reached.\n");
          terminate = TRUE;
          break;
        case GST_MESSAGE_STATE_CHANGED:
          /* We are only interested in state-changed messages from the
pipeline */
          if (GST_MESSAGE_SRC (msg) == GST_OBJECT (pipeline)) {
            GstState old_state, new_state, pending_state;
            gst_message_parse_state_changed (msg, &old_state, &new_state,
&pending_state);
            g_print ("Pipeline state changed from %s to %s:\n",
                gst_element_state_get_name (old_state),
gst_element_state_get_name (new_state));
          }
          break;
        default:
          /* We should not reach here */
          g_printerr ("Unexpected message received.\n");
          break;
      }
      gst_message_unref (msg);
    }
  } while (!terminate);
   
  /* Free resources */
  gst_object_unref (bus);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (pipeline);
  return 0;
}
   




--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/vaapidecode-could-not-be-created-tp4671789.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list