On 7/16/19 1:55 PM, Snir Sheriber wrote:
This allows to set plugin key=value properties on run time.
To add encoder plugin property use the following syntax:
-gst.prop="key=value"
Is this the correct syntax, or do you need a -c ?
Make sure syntax is accurate and that the property is supported by
the chosen plugin, wrong/invalid properties will be ignored silently.
Specific encoder available properties can be viewed by:
gst-inspect-1.0 <PLUGIN-NAME>
---
* This patch useful for encoders tuning and testing (later we can introduce
fixed encoders setups), hence not checking for validity of input.
* I dropped sstream in previous patch but i found it useful here and added it
again, alternative suggestions are welcome
---
src/gst-plugin.cpp | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/gst-plugin.cpp b/src/gst-plugin.cpp
index 4e802f1..0d8773d 100644
--- a/src/gst-plugin.cpp
+++ b/src/gst-plugin.cpp
@@ -6,6 +6,7 @@
#include <config.h>
#include <cstring>
+#include <sstream>
#include <exception>
#include <stdexcept>
#include <memory>
@@ -35,6 +36,7 @@ struct GstreamerEncoderSettings
int fps = 25;
SpiceVideoCodecType codec = SPICE_VIDEO_CODEC_TYPE_H264;
std::string encoder;
+ std::vector<std::string> prop_strings;
};
template <typename T>
@@ -180,10 +182,15 @@ GstElement *GstreamerFrameCapture::get_encoder_plugin(const GstreamerEncoderSett
encoder = factory ? gst_element_factory_create(factory, "encoder") : nullptr;
if (encoder) { // Invalid properties will be ignored silently
- /* x264enc properties */
- gst_util_set_object_arg(G_OBJECT(encoder), "tune", "zerolatency");// stillimage, fastdecode, zerolatency
- gst_util_set_object_arg(G_OBJECT(encoder), "bframes", "0");
- gst_util_set_object_arg(G_OBJECT(encoder), "speed-preset", "1");// 1-ultrafast, 6-med, 9-veryslow
+ const char *key;
+ const char *val;
+ for (int i = 1; i < settings.prop_strings.size(); i += 2) {
+ key = settings.prop_strings[i-1].c_str();
+ val = settings.prop_strings[i].c_str();
+ gst_util_set_object_arg(G_OBJECT(encoder), key, val);
+ gst_syslog(LOG_NOTICE, "Trying to set encoder property: '%s = %s'", key, val);
If gst_util_set_object_arg returns something it would be nice to add
a status to the gst_syslog
+ }
+
}
gst_plugin_feature_list_free(filtered);
gst_plugin_feature_list_free(encoders);
@@ -449,6 +456,12 @@ void GstreamerPlugin::ParseOptions(const ConfigureOption *options)
}
} else if (name == "gst.encoder") {
settings.encoder = value;
+ } else if (name == "gst.prop") {
+ std::stringstream ss(value);
+ std::string item;
+ while (std::getline(ss, item, '=')) {
+ settings.prop_strings.push_back(item);
Maybe better to get pairs.
Uri.
+ }
}
}
}
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel