Reputation: 8499
I use v0.10.34 gstreamer core, plugin-base, etc... I develop a simple filter to modify the Y component, but i would like handle all video format without using a colorspace converter between video decode and my filter.
For now I use the following cmd to test my filter:
../../Build/lin64_release/bin/gst-launch-0.10 -v filesrc location=input.mp4 ! decodebin2 name=dec ! ffmpegcolorspace ! myfilter silent=1 ! tee name=t \ t. ! queue ! filesink location=test.yuv \ t. ! queue ! ffmpegcolorspace ! ximagesink
My 1st question is, how can i force/set a specific cap(video format) as input of my filter ?
And 2nd question is, why does I get a connection with I420 format, if I use only YUY2 and UYVY as template to create my src and sink pad ?
All idea and good url on those topics will be welcome.
Upvotes: 1
Views: 659
Reputation: 8499
For the 1st question, It looks like it's the responsibility of the _set_caps
function to accept or reject a connection with a given caps. To implement that I used an array of supported caps (define as GstStaticCaps
) and in my _set_caps
function I check the intersection of caps I receive with the GstStaticCaps I used as template.
static gboolean
gst_myfilter_set_caps (GstPad * pad, GstCaps * caps)
{
Gstmyfilter *filter;
GstVideoFormat format;
int i, w, h;
gboolean isSupported;
filter = GST_NGPTVSTUB (gst_pad_get_parent (pad));
if(!gst_video_format_parse_caps(caps, &format, &w, &h)) {
if (filter->silent == FALSE) {
g_print("Unable to get video format from caps\n");
}
return FALSE;
}
isSupported = FALSE;
for (i = 0; i < G_N_ELEMENTS (gst_myfilter_video_format_caps); i++) {
if(gst_caps_can_intersect(caps, gst_static_caps_get(&gst_myfilter_video_format_caps[i]))) {
isSupported = TRUE;
break;
}
}
if(!isSupported) {
if (filter->silent == FALSE) {
g_print("that caps is not supported\n");
}
return FALSE;
}
And to the 2nd question, how to test multiple colorspace and format support, a solution can be to use a colorspace converter and a format specifier before the filter like below.
... ! ffmpegcolorspace ! video/x-raw-yuv,format=\(fourcc\)YUY2 | myfilter ! ....
Upvotes: 1