pipeline doesn't work on python but works in linux terminal

Vladimir90 samiknani at hotmail.fr
Tue Sep 22 14:28:34 PDT 2015


I tried this pipeline gst-launch-1.0 filesrc
location=/home/sami/Desktop/python/celine.mp4 ! decodebin ! theoraenc
quality=1 ! oggmux ! filesink location=/home/sami/Desktop/new.ogg

and it worked and everything was ok.

But when i coded it on Python (code is gonna follow): i had the error
message saying "element 2 could not be linked" someone can help ?

code:
import sys, os
from os import path
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gtk, Gst


GObject.threads_init()
Gst.init(None)
filename = path.join(path.dirname(path.abspath(__file__)), 'celine.mp4')
uri = filename

pipeline = Gst.Pipeline()

video_source = Gst.ElementFactory.make('filesrc', None)
decode = Gst.ElementFactory.make('decodebin', None)
encoding = Gst.ElementFactory.make('theoraenc', None)
formatting = Gst.ElementFactory.make('oggmux', None)
saving = Gst.ElementFactory.make('filesink', None)


if (not pipeline or not video_source or not decode or not encoding or not
formatting or not saving):
    print('Not all elements could be created.')
    exit(-1)

video_source.set_property('location',uri)
encoding.set_property('quality', 1)
saving.set_property('location', '/home/sami/Desktop/new.ogg')

pipeline.add(video_source)
pipeline.add(decode)
#pipeline.add(encoding)
pipeline.add(formatting)
pipeline.add(saving)

if not pipeline.add(encoding):
	print("adding failed")

if not Gst.Element.link(video_source, decode):
	print("Elements 1 could not be linked.")
    	exit(-1)

if not Gst.Element.link(decode, encoding):
	print("Elements 2 could not be linked.")
   	exit(-1)

if not Gst.Element.link(encoding, formatting):
	print("Elements 3 could not be linked.")
    	exit(-1)

if not Gst.Element.link(formatting,saving):
	print("Elements 4 could not be linked.")
    	exit(-1)

pipeline.set_state(Gst.State.PLAYING)

bus = pipeline.get_bus()

msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE,Gst.MessageType.ERROR |
Gst.MessageType.EOS)
print msg

pipeline.set_state(Gst.State.NULL)



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/pipeline-doesn-t-work-on-python-but-works-in-linux-terminal-tp4673786.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list