#!/usr/bin/env python import sys import gi gi.require_version('Gst', '1.0') gi.require_version('GLib', '2.0') gi.require_version('GObject', '2.0') from gi.repository import GLib, GObject, Gst def set_hd (caps): print ("Setting the resolution to HD") caps.set_property ("caps", Gst.Caps.from_string ("video/x-raw,height=720,width=1280")) print ("Done") return GLib.SOURCE_REMOVE def set_sd (caps): print ("Setting the resolution to SD") caps.set_property ("caps", Gst.Caps.from_string ("video/x-raw,height=480,width=640")) print ("Done") return GLib.SOURCE_REMOVE def main(args): GObject.threads_init() Gst.init(None) # x264enc works p = Gst.parse_launch ("videotestsrc ! capsfilter name=cps caps=\"video/x-raw,height=480,width=600\" ! vaapivp9enc ! rtpvp9pay ! udpsink host=\"127.0.0.1\" port=5004") caps = p.get_by_name ("cps") GLib.timeout_add_seconds(3, set_hd, caps) GLib.timeout_add_seconds(10, set_sd, caps) GLib.timeout_add_seconds(15, set_hd, caps) GLib.timeout_add_seconds(25, set_sd, caps) p.set_state (Gst.State.PLAYING) GObject.MainLoop().run() if __name__ == '__main__': sys.exit(main(sys.argv))