from gi.repository import Gst

if __name__ == "__main__":
    Gst.init([])

    orig = Gst.Structure.new_from_string("video/x-raw")
    caps = Gst.Caps.new_empty_simple("video/x-raw")
    caps.set_value("width", 1024)
    caps.set_value("height", 768)
    orig.set_value("caps", caps)
    s = orig.to_string()
    print s
    print "number of fields before serialization :", orig.n_fields()
    dup = Gst.Structure.new_from_string(s)
    print dup.to_string()
    print "nbr of fields after deserialization:", dup.n_fields()
