• Hardware Platform (Jetson / GPU) Orin AGX
• DeepStream Version 6.1.1
• JetPack Version (valid for Jetson only) 5.0.2
• TensorRT Version 8.4.1.5
• How to reproduce the issue ?
I have the following pipeline that uses an appsrc element to feed frames into a pipeline in form of numpy arrays. It works as expected, i.e. I can see the visualization of the frames.
GObject.threads_init()
Gst.init(None)
pipeline = Gst.Pipeline()
appsource = Gst.ElementFactory.make("appsrc", "numpy-source")
caps_in = Gst.Caps.from_string("video/x-raw, format=RGBA, width=640, height=480, framerate=30/1")
appsource.set_property('caps', caps_in)
nvvideoconvert = Gst.ElementFactory.make("nvvideoconvert","nv-videoconv")
caps_filter = Gst.ElementFactory.make("capsfilter","capsfilter1")
caps = Gst.Caps.from_string("video/x-raw(memory:NVMM),format=NV12,width=640,height=480,framerate=30/1")
caps_filter.set_property('caps',caps)
egltransform = Gst.ElementFactory.make("nvegltransform", "nvegl-transform")
sink = Gst.ElementFactory.make("nveglglessink", "nvvideo-renderer")
# --- Add elements to pipeline
pipeline.add(appsource)
pipeline.add(nvvideoconvert)
pipeline.add(caps_filter)
pipeline.add(egltransform)
pipeline.add(sink)
# --- Link elements
appsource.link(nvvideoconvert)
nvvideoconvert.link(caps_filter)
caps_filter.link(egltransform)
egltransform.link(sink)
# --- Create an event loop and feed gstreamer bus mesages to it
loop = GObject.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect ("message", bus_call, loop)
# --- Start play back and listen to events
pipeline.set_state(Gst.State.PLAYING)
# --- Push numpy array to appsrc
for _ in range(10):
arr = np.random.randint(low=0,high=255,size=(480,640,3), dtype=np.uint8)
arr = cv2.cvtColor(arr, cv2.COLOR_BGR2RGBA)
appsource.emit("push-buffer", self._ndarray_to_gst_buffer(arr))
time.sleep(0.3)
appsource.emit("end-of-stream")
try:
loop.run()
except:
pass
# --- Cleanup
pipeline.set_state(Gst.State.NULL)
Now I am trying to modify the pipeline in order to save the output to a file. So I have modified the above pipeline by substituting:
nvegltransform -> nveglglessink
with:
nvv4l2h264enc -> h264parse -> qtmux -> filesink
To create the new elements I use:
encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder")
encoder.set_property('bitrate', 4000000)
encoder.set_property('preset-level', 1)
encoder.set_property('insert-sps-pps', 1)
parser = Gst.ElementFactory.make("h264parse", "parser")
qtmux = Gst.ElementFactory.make("qtmux", "muxer")
filesink = Gst.ElementFactory.make("filesink", "filesink")
filesink.set_property("location", 'out.mp4')
filesink.set_property("sync", 0)
filesink.set_property("async", 0)
This is how I am linking the elements:
appsource.link(nvvideoconvert)
nvvideoconvert.link(caps_filter)
caps_filter.link(encoder)
encoder.link(parser)
parser.link(qtmux)
qtmux.link(filesink)
and this is how my pipeline terminates:
try:
loop.run()
except:
pass
Gst.Element.send_event(pipeline, Gst.Event.new_eos())
pipeline.set_state(Gst.State.NULL)
The above code generates an mp4 file but unfortunately the file is not playable, e.g. using vlc. I would expect to see a video similar to the output I get displayed on screen when using nveglglessink.