gst-interpipe icon indicating copy to clipboard operation
gst-interpipe copied to clipboard

Unable to make simple python example run

Open superlou opened this issue 8 years ago • 5 comments

I am trying to debug a more complex interpipe application and made a simpler example to try it out:

import gi
from gi.repository import GObject
import os
import sys

try:
    gi.require_version('Gst', '1.0')
except ValueError:
    print 'Could not find required Gstreamer library'
    sys.exit(1)

from gi.repository import Gst


def make_src_pipeline():
    pipeline = Gst.Pipeline()
    src = Gst.ElementFactory.make('videotestsrc', None)
    sink = Gst.ElementFactory.make('interpipesink', None)
    sink.set_property('name', 'output')
    pipeline.add(src)
    pipeline.add(sink)
    src.link(sink)
    pipeline.set_state(Gst.State.PLAYING)


def make_sink_pipeline():
    pipeline = Gst.Pipeline()
    src = Gst.ElementFactory.make('interpipesrc', None)
    sink = Gst.ElementFactory.make('xvimagesink', None)
    src.set_property('listen-to', 'output')
    pipeline.add(src)
    pipeline.add(sink)
    src.link(sink)
    pipeline.set_state(Gst.State.PLAYING)

def make_simple_pipeline():
    pipeline = Gst.Pipeline()
    src = Gst.ElementFactory.make('videotestsrc', None)
    sink = Gst.ElementFactory.make('xvimagesink', None)
    pipeline.add(src)
    pipeline.add(sink)
    src.link(sink)
    pipeline.set_state(Gst.State.PLAYING)

if __name__ == "__main__":
    os.environ["GST_DEBUG"] = '2'
    Gst.init(None)
    # make_simple_pipeline()
    make_src_pipeline()
    make_sink_pipeline()

    while 1:
        pass

The pipeline created by make_simple_pipeline shows the video test source as expected. However, if I run the script as shown with the two interpipe pipelines, no video window appears. The attached errors.txt file contains the error outputs at GST debug level 4. errors.txt

There's definitely something happening in the background, because if I leave the program running (even with a low log level), eventually the PC slows down, including mouse movements.

Are there properties I need to set on the interpipe elements in this simple pipeline?

superlou avatar Aug 18 '16 01:08 superlou

Hi,

Checkout the examples in the GstInterpipe wiki

I’m closing this issue because it has been inactive for a long time. Please feel free to reopen if you still encounter this issue.

jcaballeros avatar Sep 24 '20 18:09 jcaballeros

Hi @jcaballeros

Are there tested examples of GstInterpipe in Python? The wiki you linked above only has examples in bash

rsnk96 avatar Nov 03 '20 18:11 rsnk96

Hi,

No, we currently don't have any gst-python + interpipe examples in our wiki, but I think that interpipe should work well with gst-python.

jcaballeros avatar Nov 04 '20 18:11 jcaballeros

I'd like a few python examples on how to show usage and catching events.

SonnyWalkman avatar Jan 07 '21 13:01 SonnyWalkman

@superlou Hi,I am changed your code, that can work , thanks for your code !

import gi
from gi.repository import GObject
import os
import sys

try:
    gi.require_version('Gst', '1.0')
except ValueError:
    print ('Could not find required Gstreamer library')
    sys.exit(1)

from gi.repository import Gst


def make_src_pipeline():
    pipeline = Gst.Pipeline()

    src = Gst.ElementFactory.make('videotestsrc', None)
    sink = Gst.ElementFactory.make('interpipesink', None)
    
    sink.set_property('name', 'output1')
    src.set_property('is-live',True)
    
    pipeline.add(src)
    pipeline.add(sink)
    
    src.link(sink)
    
    pipeline.set_state(Gst.State.PLAYING)

def make_sink_pipeline():
    pipeline = Gst.Pipeline()

    src = Gst.ElementFactory.make('interpipesrc', None)
    conv = Gst.ElementFactory.make('videoconvert',None)
    sink = Gst.ElementFactory.make('ximagesink', None)

    src.set_property('listen-to', 'output1')
    
    pipeline.add(src)
    pipeline.add(conv)
    pipeline.add(sink)
    
    src.link(conv)
    conv.link(sink)
    
    pipeline.set_state(Gst.State.PLAYING)

if __name__ == "__main__":
    os.environ["GST_DEBUG"] = '2'
    Gst.init(None)
    
    make_src_pipeline()
    make_sink_pipeline()

    while 1:
        pass

AadeIT avatar Sep 14 '21 03:09 AadeIT