va: baseenc: Check the bitrate property before get its value

Not all the encoders have the bitrate property, such as the jpeg enc.
We need to check that property before getting its value, or the glib
will print warnings.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6022>
This commit is contained in:
He Junyan 2024-08-30 23:00:48 +08:00 committed by GStreamer Marge Bot
parent 9327458cfb
commit f7e434028d

View file

@ -1194,7 +1194,9 @@ gst_va_base_enc_add_codec_tag (GstVaBaseEnc * base, const gchar * codec_name)
const gchar *encoder_name;
guint bitrate = 0;
g_object_get (venc, "bitrate", &bitrate, NULL);
if (g_object_class_find_property (G_OBJECT_GET_CLASS (base), "bitrate"))
g_object_get (venc, "bitrate", &bitrate, NULL);
if (bitrate > 0)
gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_NOMINAL_BITRATE,
bitrate, NULL);