Hi all,
Any Gstreamer experts around here? I have been modding the ofGstVideoPlayer class to make it use a custom pipeline instead of playbin. It works however I don’t really like how it performs. In Gstreamer the stream is much more stable and doesn’t smear (is that the right word for h264 artefacts?) I’m not sure how OF implemented Gstreamer but I guess it’s just grabbing pixels from the appsink element?
Basically what I did is change the createPipeline method to use gst_parse_launch and then link the appsink manually at the end.
bool ofCustomGstVideoPlayer::createPipeline(string name){
GstElement * gstPipeline = gst_parse_launch("udpsrc port=5000 ! application/x-rtp,encoding-name=H264,payload=96 ! rtph264depay ! h264parse ! avdec_h264 ! autovideoconvert name=decode" , NULL);
//GstElement * gstPipeline = gst_element_factory_make("playbin","player");
//g_object_set(G_OBJECT(gstPipeline), "port", name.c_str(), (void*)NULL);
// create the oF appsink for video rgb without sync to clock
GstElement * gstSink = gst_element_factory_make("appsink", "app_sink");
gst_base_sink_set_sync(GST_BASE_SINK(gstSink), true);
gst_app_sink_set_max_buffers(GST_APP_SINK(gstSink), 8);
gst_app_sink_set_drop (GST_APP_SINK(gstSink),true);
gst_base_sink_set_max_lateness (GST_BASE_SINK(gstSink), -1);
string mime="video/x-raw";
GstCaps *caps;
if(internalPixelFormat==OF_PIXELS_NATIVE){
//caps = gst_caps_new_any();
caps = gst_caps_from_string((mime + ",format={RGBA,BGRA,RGB,BGR,RGB16,GRAY8,YV12,I420,NV12,NV21,YUY2}").c_str());
/*
GstCapsFeatures *features = gst_caps_features_new (GST_CAPS_FEATURE_META_GST_VIDEO_GL_TEXTURE_UPLOAD_META, NULL);
gst_caps_set_features (caps, 0, features);*/
}else{
string format = ofGstVideoUtils::getGstFormatName(internalPixelFormat);
caps = gst_caps_new_simple(mime.c_str(),
"format", G_TYPE_STRING, format.c_str(),
NULL);
ofLogWarning() << "caps: " << gst_caps_to_string(caps);
}
gst_app_sink_set_caps(GST_APP_SINK(gstSink), caps);
gst_caps_unref(caps);
//g_object_set (G_OBJECT(gstPipeline),"video-sink",gstSink,(void*)NULL);
gst_bin_add(GST_BIN(gstPipeline), gstSink);
GstElement* decbin = gst_bin_get_by_name(GST_BIN(gstPipeline),"decode");
gst_element_link (decbin, gstSink);
gst_object_unref(decbin);
return videoUtils.setPipelineWithSink(gstPipeline,gstSink,bIsStream);
}