It may be related to gstd or to your pipeline, or plugins failing to keep sync.
You may try this simple example launching a gstreamer pipeline going from camera source → h264enc → h264dec → videosink (needs sync=false in R32.5), where you can pause the pipeline and restart (stopping and restarting also works):
#!/usr/bin/env python
import sys, os
import gi
gi.require_version('Gst', '1.0')
gi.require_version('Gtk', '3.0')
from gi.repository import Gst, GObject, Gtk
def verbose_deep_notify_cb(object, orig, pspec, component):
"""
A quick attempt to mimic gst-launch verbose mode.
"""
if pspec.value_type == Gst.Caps.__gtype__:
caps = orig.get_current_caps()
if caps != None:
print("%s/%s/%s: caps = \"%s\"" % (object.get_name(), orig.parent.get_name(), orig.get_name(), caps.to_string()))
class GTK_Main:
def __init__(self):
window = Gtk.Window(Gtk.WindowType.TOPLEVEL)
window.set_title("CamRecorder")
window.set_default_size(100, 100)
window.connect("destroy", Gtk.main_quit, "WM destroy")
vbox = Gtk.VBox()
window.add(vbox)
hbox = Gtk.HBox()
vbox.pack_start(hbox, False, False, 0)
hbox.set_border_width(10)
hbox.pack_start(Gtk.Label(), False, False, 0)
self.button = Gtk.Button("Start")
self.button.connect("clicked", self.start_stop)
hbox.pack_start(self.button, False, False, 0)
self.button2 = Gtk.Button("Quit")
self.button2.connect("clicked", self.exit)
hbox.pack_start(self.button2, False, False, 0)
hbox.add(Gtk.Label())
window.show_all()
# Set up the gstreamer pipeline
# IMX219 sensor on CSI-0
#gst_str = "nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1 ! nvv4l2h264enc ! nvv4l2decoder enable-max-performance=1 ! nvvidconv ! xvimagesink sync=false"
# ZED camera on /dev/video1
gst_str = "v4l2src device=/dev/video1 ! video/x-raw,format=YUY2, width=2560, height=720, framerate=30/1 ! nvvidconv ! nvv4l2h264enc ! nvv4l2decoder enable-max-performance=1 ! nvvidconv ! xvimagesink sync=false"
self.player = Gst.parse_launch (gst_str)
self.player.connect('deep-notify', verbose_deep_notify_cb, self)
bus = self.player.get_bus()
bus.add_signal_watch()
bus.enable_sync_message_emission()
bus.connect("message", self.on_message)
def start_stop(self, w, data=None):
if self.button.get_label() == "Start":
print("Setting pipeline to READY ...")
self.player.set_state(Gst.State.READY)
print("Setting pipeline to PAUSED ...")
self.player.set_state(Gst.State.PAUSED)
print("Setting pipeline PLAYING...")
self.player.set_state(Gst.State.PLAYING)
self.button.set_label("Pause")
elif self.button.get_label() == "Resume":
print("Setting pipeline to PLAYING ...")
self.player.set_state(Gst.State.PLAYING)
self.button.set_label("Pause")
else:
print("Setting pipeline to PAUSED ...")
self.player.set_state(Gst.State.PAUSED)
self.button.set_label("Resume")
def exit(self, w):
self.player.set_state(Gst.State.NULL)
Gtk.main_quit()
def on_message(self, bus, message):
t = message.type
if t == Gst.MessageType.EOS:
print('Received message type EOS')
self.player.set_state(Gst.State.NULL)
self.button.set_label("Start")
elif t == Gst.MessageType.ERROR:
err, debug = message.parse_error()
print("Error: %s" % err, debug)
self.player.set_state(Gst.State.NULL)
self.button.set_label("Start")
Gst.debug_set_active(True)
Gst.debug_set_default_threshold(0)
GObject.threads_init()
Gst.init(None)
GTK_Main()
Gtk.main()