This is my pipeline
import gi
gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import Gst
from gi.repository import Gst, GObject
Initialize GStreamer
Gst.init(None)
Create elements
filesrc = Gst.ElementFactory.make(“filesrc”, “source”)
filesrc.set_property(“location”, “/opt/nvidia/deepstream/deepstream/samples/streams/sonyc_mixed_audio.wav”)
decodebin = Gst.ElementFactory.make(“decodebin”, “decoder”)
audioconvert = Gst.ElementFactory.make(“audioconvert”, “convert”)
audioresample = Gst.ElementFactory.make(“audioresample”, “resample”)
queue = Gst.ElementFactory.make(“queue”, “queue”)
nvstreammux = Gst.ElementFactory.make(“nvstreammux”, “mux”)
nvstreammux.set_property(“batch-size”, 1)
nvstreammux.set_property(“width”, 1280)
nvstreammux.set_property(“height”, 720)
nvstreammux.set_property(“live-source”, False)
nvstreammux.set_property(“gpu-id”, 0)
nvinferaudio = Gst.ElementFactory.make(“nvinferaudio”, “audio_infer”)
nvinferaudio.set_property(“config-file-path”, “/opt/nvidia/deepstream/deepstream/sources/apps/sample_apps/deepstream-audio/configs/config_infer_audio_sonyc2.txt”)
nvinferaudio.set_property(“batch-size”, 1)
nvinferaudio.set_property(“gpu-id”, 0)
autoaudiosink = Gst.ElementFactory.make(“autoaudiosink”, “audio_sink”)
Create a GStreamer pipeline
pipeline = Gst.Pipeline.new(“audio_pipeline”)
Add elements to the pipeline
pipeline.add(filesrc)
pipeline.add(decodebin)
pipeline.add(audioconvert)
pipeline.add(audioresample)
pipeline.add(queue)
pipeline.add(nvstreammux)
pipeline.add(nvinferaudio)
pipeline.add(autoaudiosink)
Link elements (decodebin will be linked dynamically, the rest are linked statically)
filesrc.link(decodebin)
Dynamic linking for decodebin (connecting decodebin to audioconvert)
def on_pad_added(decodebin, pad):
caps = pad.query_caps(None)
if caps.to_string().startswith(“audio/x-raw”):
pad.link(audioconvert.get_static_pad(“sink”))
decodebin.connect(“pad-added”, on_pad_added)
decodebin.link(audioconvert)
Link the remaining elements
audioconvert.link(audioresample)
audioresample.link(queue)
queue_src_pad = queue.get_static_pad(“src”)
mux_sink_pad = nvstreammux.get_request_pad(“sink_0”)
queue_src_pad.link(mux_sink_pad)
queue.link(nvstreammux)
nvstreammux.link(nvinferaudio)
nvinferaudio.link(autoaudiosink)
pipeline.set_state(Gst.State.PLAYING)
Run the pipeline
try:
bus = pipeline.get_bus()
msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.EOS | Gst.MessageType.ERROR)
if msg:
if msg.type == Gst.MessageType.ERROR:
err, debug = msg.parse_error()
print(f"Error: {err}, {debug}")
finally:
# Stop the pipeline
pipeline.set_state(Gst.State.NULL)
Can you check if this is fine?