My notes on batch-size are:
you can’t dynamically set the batch size on nvinfer, at least in the playing state (eg. i haven’t tried PAUSED). It should be set to the number of sources, ideally.
on nvinfer, the engine file also depends on the batch size, so there currently needs to be one engine file generated per batch size, and you need to figure out it’s filename and set that at runtime to override the config file (or else it will take minutes at a time to rebuild).
on the stream-muxer element you absolutely can set the sources in the paused state. I am setting it in my pad added callback when a source is linked. Yesterday I experienced some odd flickering when I tried to set batch size to 4 before connecting all 4 sources. Instead, I am setting the batch size to the number of sink pads on the stream muxer in my on_source_pad_added callback (called on “pad-added” signal from uridecodebin):
... rest of Genie class ...
def _on_src_pad_added(src:Gst.Element, src_pad:Gst.Pad)
debug(@"got new pad $(src_pad.name) from $(src.name)")
// if not a video/NVMM pad, reject it
src_caps:Gst.Caps = src_pad.query_caps(null)
src_pad_struct:weak Gst.Structure = src_caps.get_structure(0)
src_pad_type:string = src_pad_struct.get_name()
if not src_pad_type.has_prefix("video/x-raw")
debug(@"$(src_pad.name) is not a video pad. skipping.")
// without this lock it's possible to request multiple identical pads like:
// Padname sink_0 is not unique in element muxer, not adding
debug(@"getting muxer lock for $(src.name)")
debug(@"got muxer lock for $(src.name)")
sink_pad:Gst.Pad = self._muxer.get_request_pad(@"sink_$(self._muxer.numsinkpads)")
if sink_pad == null
error("could not request sink pad from multiqueue")
// this needs to be updated on pad added or flickering occurs with the osd
[b] self._muxer.set_property("batch-size", self._muxer.numsinkpads)
debug(@"releasing muxer lock for $(src.name)")
debug(@"released muxer lock for $(src.name)")
Warning: the above function locks up about half the time with many sources. I belive it may be deadlocking. I am not familiar enough with GLib or this sort of concurrency yet to be sure. If you know, and can spot the error, I would greatly appreciate if it was pointed out. Likewise, please don’t hesitate to correct me, Nvidia if there is any misinformation here.