def start_recording(self, obj, format, profile, inline_headers, bitrate, intra_period): def on_buffer(data, _): obj.write(data) def render_overlay(tensor, layout, command): if self.render_overlay: self.render_overlay(tensor, layout, command) return None def stupid_overlay(tensor, layout, command): if self.stupid_overlay: self.stupid_overlay(self, tensor, layout, command) # image = tensor.reshape(480, 640, 3) # im = Image.fromarray(image) # im.save("test.jpeg") # print(tensor.shape) #Image.fromarray(tensor).convert("RGB").save("art.png") return None signals = { 'h264sink': {'new-sample': gstreamer.new_sample_callback(on_buffer)}, } pipeline = self.make_pipeline(format, profile, inline_headers, bitrate, intra_period) self._thread = threading.Thread(target=gstreamer.run_pipeline, args=(pipeline, self._layout, self._loop, render_overlay, stupid_overlay, gstreamer.Display.NONE, False, signals)) self._thread.start()
def start_recording(self, obj, format, profile, inline_headers, bitrate, intra_period): def on_buffer(data, _): obj.write(data) def render_overlay(tensor, layout, command): if self.render_overlay: self.render_overlay(tensor, layout, command) return None signals = { 'h264sink': { 'new-sample': gstreamer.new_sample_callback(on_buffer) }, } pipeline = self.make_pipeline(format, profile, inline_headers, bitrate, intra_period) self._thread = threading.Thread( target=gstreamer.run_pipeline, args=(pipeline, self._layout, self._loop, render_overlay, gstreamer.Display.NONE, False, signals)) self._thread.start()