getting streaming stopped, reason not-negotiated (-4) error

manas_mandal mandalmanas786 at gmail.com
Sun May 17 06:06:19 UTC 2020


I have below code which read the frame from video capture card and push those
frames are gst buffer to appsrc element but when i run the code i am getting
getting streaming stopped, reason not-negotiated (-4) error i am suspecting
there is some issue with my caps assignement

import sys
import gi
import os
import threading
import traceback
gi.require_version("Gst", "1.0")
from gi.repository import GObject, Gst  # pylint:disable=wrong-import-order

Gst.init([])


class LiveStreamingDUT(object):
    def __init__(self, display):
        self.end_of_stream = False
        self.vsrc = None

    def __stream_dut(self):
        try:
            pipeline_command =* "appsrc name=videosrc is-live=true
block=true caps=image/jpeg,framerate=(fraction)30/1 ! videoconvert ! x264enc
tune=zerolatency ! " \
                               "mpegtsmux ! " \
                               "hlssink location=/var/www/segment-%05d.ts "
\
                               "playlist-location=/var/www/index.m3u8
max-files=20 " \
                               "target-duration=15"*

            print(pipeline_command)

            pipeline = Gst.parse_launch(pipeline_command)
            self.vsrc = pipeline.get_by_name('videosrc')

            r = PipelineRunner(pipeline)
            thread = threading.Thread(target=r.run)
            thread.daemon = True
            thread.start()

            writerThread = threading.Thread(target=self._appsrc_push_data,
name='gstreamerpushdata')
            writerThread.start()

        except:
            print('error during streaming content')
            print("teardown: Exiting (GLib mainloop %s)" % (
                "is still alive!" if thread.isAlive() else "ok"))

    def _appsrc_push_data(self):
        try:
            while (self.end_of_stream == False):
                try:
                    ret, data = <read frame from hdmi capture card and
return in numpy array>
                    buf = self.ndarray_to_gst_buffer(data)
                    self.vsrc.emit('push-buffer', buf)
                except:
                    traceback.print_exc()
                    print("Error reading HDMI data")
                    self.end_of_stream = True
                    break
        except:
            print("EXCEPTION:StefHdmi.__frame_write()")
        finally:
            print("Existing Frame write thread")

    def ndarray_to_gst_buffer(self, array):
        """Converts numpy array to Gst.Buffer"""
        return Gst.Buffer.new_wrapped(array.tobytes())

    def stream_dut(self):
        self.__stream_dut()


class PipelineRunner(object):
    """Provides an easy way to run a pre-constructed Gstreamer pipeline much
    like gst-launch"""

    def __init__(self, pipeline):
        self.mainloop = GObject.MainLoop()
        self.err, self.dbg = None, None

        def on_error(_bus, message):
            self.err, self.dbg = message.parse_error()
            self.mainloop.quit()

        def on_warning(_bus, message):
            assert message.type == Gst.MessageType.WARNING
            _err, _dbg = message.parse_warning()
            sys.stderr.write("Warning: %s: %s\n%s\n" % (_err, _err.message,
                                                        _dbg))

        def on_eos(_bus, _message):
            pipeline.set_state(Gst.State.NULL)
            self.mainloop.quit()

        bus = pipeline.get_bus()
        bus.connect("message::eos", on_eos)
        bus.connect("message::error", on_error)
        bus.connect("message::warning", on_warning)
        bus.add_signal_watch()

        pipeline.set_state(Gst.State.PLAYING)
        self.pipeline = pipeline

    def run(self):
        self.mainloop.run()
        if self.err is not None:
            raise RuntimeError("Error running pipeline: %s\n\n%s" %
                               (self.err, self.dbg))

    def __del__(self):
        self.pipeline.set_state(Gst.State.NULL)
        self.pipeline.get_state(0)

Getting error message

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/threading.py", line 926, in
_bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "./display/gst_live_stream.py", line 111, in run
    (self.err, self.dbg))
RuntimeError: Error running pipeline: gst-stream-error-quark: Internal data
stream error. (1)

gstbasesrc.c(3055): gst_base_src_loop ():
/GstPipeline:pipeline0/GstAppSrc:videosrc:
streaming stopped, reason not-negotiated (-4)

My video capture card details


Driver Info:
        Driver name      : uvcvideo
        Card type        : ezcap U3 capture: ezcap U3 capt
        Bus info         : usb-0000:00:1d.0-1.5
        Driver version   : 4.15.18
        Capabilities     : 0x84200001
                Video Capture
                Streaming
                Extended Pix Format
                Device Capabilities
        Device Caps      : 0x04200001
                Video Capture
                Streaming
                Extended Pix Format
Media Driver Info:
        Driver name      : uvcvideo
        Model            : ezcap U3 capture: ezcap U3 capt
        Serial           :
        Bus info         : usb-0000:00:1d.0-1.5
        Media version    : 4.15.18
        Hardware revision: 0x00000100 (256)
        Driver version   : 4.15.18
Interface Info:
        ID               : 0x03000002
        Type             : V4L Video
Entity Info:
        ID               : 0x00000001 (1)
        Name             : ezcap U3 capture: ezcap U3 capt
        Function         : V4L2 I/O
        Pad 0x01000004   : Sink
          Link 0x02000010: from remote pad 0x1000007 of entity 'Extension
4': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
        Width/Height      : 1920/1080
        Pixel Format      : 'MJPG' (Motion-JPEG)
        Field             : None
        Bytes per Line    : 0
        Size Image        : 4147200
        Colorspace        : sRGB
        Transfer Function : Default (maps to sRGB)
        YCbCr/HSV Encoding: Default (maps to ITU-R 601)
        Quantization      : Default (maps to Full Range)
        Flags             :
Crop Capability Video Capture:
        Bounds      : Left 0, Top 0, Width 1920, Height 1080
        Default     : Left 0, Top 0, Width 1920, Height 1080
        Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags:
Streaming Parameters Video Capture:
        Capabilities     : timeperframe
        Frames per second: 30.000 (30/1)
        Read buffers     : 0
                     brightness 0x00980900 (int)    : min=0 max=255 step=1
default=128 value=128
                       contrast 0x00980901 (int)    : min=0 max=255 step=1
default=128 value=128
                     saturation 0x00980902 (int)    : min=0 max=255 step=1
default=128 value=128
                            hue 0x00980903 (int)    : min=-32 max=31 step=1
default=0 value=0





--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list