Error 'not negotiated' from ffmpegcolorspace.

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error 'not negotiated' from ffmpegcolorspace.

wl2776
Administrator
I am writing a small function, making screenshots, I've wrote about it in my previous message.
Now, instead of setting pad's caps, I'm trying to use capsfilter.

My function gets the last displayed buffer from the videosink, then builds the pipeline:
appsrc -> ffmpegcolorspace -> videoscale -> capsfilter -> encoder -> filesink

However, my problem in another place.
After adding some debug messages, I've found that ffmpegcolorspace for some reason cannot negotiate.
Why?
What does it want?

My code:
/*  get last-buffer from videosink   */
pipeline=(GstPipeline *)gst_pipeline_new("ipipeline");
bus=gst_pipeline_get_bus(pipeline);
		
appsrc=(GstAppSrc *)gst_element_factory_make("appsrc","appsrc0");
colorconv=gst_element_factory_make("ffmpegcolorspace","colorconv");
videoscale=gst_element_factory_make("videoscale","videoscale");
capsflt=gst_element_factory_make("capsfilter","capsfilter");

if(width && height){
  caps=gst_caps_new_simple("video/x-raw-rgb",
                                        "bpp",G_TYPE_INT,24,
                                        "depth",G_TYPE_INT,24,
                                        "width",G_TYPE_INT,width,
                                        "height",G_TYPE_INT,height,
                                        NULL);
}else{
  caps=gst_caps_new_simple("video/x-raw-rgb",
                                        "bpp",G_TYPE_INT,24,
                                        "depth",G_TYPE_INT,24,
                                        NULL);
}

g_object_set(capsflt,"caps",caps,NULL);
gst_object_unref(caps);

switch(format){
case 1: //jpeg
  enc=gst_element_factory_make("jpegenc","jpeg"); 
  break;
case 2: //bmp
  enc=gst_element_factory_make("ffenc_bmp","bmp"); 
  break;
case 3: //png
  enc=gst_element_factory_make("pngenc","png"); 
  break;
case 4: //tiff
  enc=gst_element_factory_make("ffenc_tiff","tiff"); 
  break;
}

filesink=gst_element_factory_make("filesink","fsink");
g_object_set(filesink,"location",filename,NULL);

gst_bin_add_many(GST_BIN(pipeline),GST_ELEMENT(appsrc),colorconv,videoscale,capsflt,enc,filesink,NULL);
rb=gst_element_link_many(GST_ELEMENT(appsrc),colorconv,videoscale,capsflt,enc,filesink,NULL);

gst_app_src_set_stream_type(appsrc,GST_APP_STREAM_TYPE_STREAM);

GstAppSrcCallbacks callbacks;
callbacks.need_data=need_data;  // this callback pushes the buffer to the ipipeline and also the eos.
callbacks.enough_data=NULL;
callbacks.seek_data=NULL;
gst_app_src_set_callbacks(appsrc,&callbacks,this,NULL);

if(rb){
  gst_element_set_state(GST_ELEMENT(pipeline),GST_STATE_PLAYING);
  while(1){  //pop messages from the bus and process them without running the main loop
    msg=gst_bus_pop(bus);
   //process messages.
  }
}

And I can see in the debug output that colorspace always gives the error 'not negotiated'.
If I leave only appsrc, colorspace and filesink in gst_bin_add_many and gst_bin_link_many, then I get a file on disk and no errors...
Reply | Threaded
Open this post in threaded view
|

Re: Error 'not negotiated' from ffmpegcolorspace.

wl2776
Administrator
Sorry, mistake:
wl2776 wrote
If I leave only appsrc and filesink in gst_bin_add_many and gst_bin_link_many, then I get a file on disk and no errors...
Only two elements in the pipeline give no errors.
The pipeline of three elements: appsrc->colorspace->filesink does give the 'not negotiated' error.
Colorspace doesn't negotiate.
Reply | Threaded
Open this post in threaded view
|

Re: Error 'not negotiated' from ffmpegcolorspace.

wl2776
Administrator
In reply to this post by wl2776
Solved.
I have just set caps from the GstBuffer, I already have, on the appsrc.

Looks like colorspace had too many variants, and could not decide which one to choose.
Reply | Threaded
Open this post in threaded view
|

Re: Error 'not negotiated' from ffmpegcolorspace.

Jesse
thank you,I have struggled on this problem for there days ,you saved my life!