0

When working in Python 3 with gstreamer, there is a bunch of "uncapturable" output to the console, as it seems that the logging is coming from deep within gstreamer and its plugins and NOT the python bindings. Wherever that's coming from, it also doesn't register a python logging handler of its own (e.g., you can't "grab" it and decorate it using something like logging.getLogger("gi"), because there is nothing registered by it. I used https://stackoverflow.com/a/60381742/13902318 to list everything and there was nothing in the output that was related to gstreamer at all).

Example program output:

[2023-03-08 19:12:08,305] [INFO] - Log messages that follow to stdout come from gstreamer ...
Opening in BLOCKING MODE 
gstnvtracker: Loading low-level lib at /opt/nvidia/deepstream/deepstream/lib/libnvds_nvmultiobjecttracker.so
gstnvtracker: Batch processing is ON
gstnvtracker: Past frame output is ON
[NvMultiObjectTracker] Initialized
0:00:15.712232965     1      0xd6c3a60 INFO                 nvinfer gstnvinfer.cpp:646:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::deserializeEngineAndBackend() <nvdsinfer_context_impl.cpp:1909> [UID = 1]: deserialized trt engine from :/model/model.engine
0:00:15.801714684     1      0xd6c3a60 INFO                 nvinfer gstnvinfer.cpp:646:gst_nvinfer_logger:<primary-inference> NvDsInferContext[UID 1]: Info from NvDsInferContextImpl::generateBackendContext() <nvdsinfer_context_impl.cpp:2012> [UID = 1]: Use deserialized engine model: /model/model.engine
0:00:15.812508485     1      0xd6c3a60 INFO                 nvinfer gstnvinfer_impl.cpp:328:notifyLoadModelStatus:<primary-inference> [UID 1]: Load new model:/config/modip_pgie_config.txt sucessfully
NvMMLiteOpen : Block : BlockType = 279 
NVMEDIA: Reading vendor.tegra.display-size : status: 6 
NvMMLiteBlockCreate : Block : BlockType = 279 
NvMMLiteOpen : Block : BlockType = 4 
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4 
H264: Profile = 66, Level = 0 
NVMEDIA: Need to set EMC bandwidth : 846000 
NVMEDIA: Need to set EMC bandwidth : 846000 
NVMEDIA_ENC: bBlitMode is set to TRUE 
[2023-03-08 19:12:24,633] [INFO] - Writing to file...

The first and last lines of that excerpt are generated by a custom logging class I have defined, the details of which aren't important. To a degree, neither is the code used to get here, since this issue exists in any sample code using the python gstreamer bindings.

I also tried using code similar to this (using my own logging class) also does not result in those messages redirecting. They're always printed to stderr/stdout.

I have also tried without success to redirect stderr and stdout (e.g., something like this also doesn't work, presumably since what's happening with Gstreamer is in a C submodule.

Any assistance would be appreciated.

RyanJ
  • 63
  • 7

0 Answers0