porting command line to python

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

porting command line to python

jagernicolas
Hi,
I'm not very familiar with gstreamer and I struggling to port a command line to python. Here the command line (linux):

$ gst-launch-1.0 -e rtspsrc location=rtsp://<user>:<password>@<ip>/<path>/media.amp latency=60 protocols=tcp ! rtph264depay ! h264parse ! splitmuxsink location=my_test.mov max-size-time=10000000000 max-size-bytes=40000000

I wrote this python script:

import time
import sys
import gi
gi.require_version('GLib', '2.0')
gi.require_version('Gst', '1.0')
from gi.repository import GLib, Gst

Gst.init(sys.argv)

print (Gst.MessageType)

def on_message(bus, message):
t = message.type

print("[[", t , "]]")

if t == Gst.MessageType.ERROR:
my_pipeline.set_state(Gst.State.NULL)
err, debug = message.parse_error()
print("(ERR): %s" % err, debug)



my_pipeline = Gst.Pipeline.new("my-pipeline")
assert my_pipeline
print(my_pipeline)

my_rtspsrc = Gst.ElementFactory.make("rtspsrc", "rtspsrc")
assert my_rtspsrc
print(my_rtspsrc)

#my_rtspsrc.set_property("location", "rtsp://<ip>/<path>/media.amp")
my_rtspsrc.set_property("location", "rtsp://<user>:<password>@<ip>/<path>/media.amp")
my_rtspsrc.set_property("latency", 60)
my_rtspsrc.set_property("protocols", "tcp")

#my_rtspsrc.set_property("user-id", "<user>")
#my_rtspsrc.set_property("user-pw", "<password>")

my_rtph264depay = Gst.ElementFactory.make("rtph264depay", "rtph264depay")
assert my_rtph264depay
print(my_rtph264depay)

my_h264parse = Gst.ElementFactory.make("h264parse", "h264parse")
assert my_h264parse
print(my_h264parse)

my_splitmuxsink = Gst.ElementFactory.make("splitmuxsink", "splitmuxsink")
assert my_splitmuxsink
print(my_splitmuxsink)
my_splitmuxsink.set_property("max-size-time", 10000000000)
my_splitmuxsink.set_property("max-size-bytes", 40000000)
my_splitmuxsink.set_property("location", "my_test.mov")

bus = my_pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", on_message)

my_pipeline.add(my_rtspsrc)
my_pipeline.add(my_rtph264depay)
my_pipeline.add(my_h264parse)
my_pipeline.add(my_splitmuxsink)

my_rtspsrc.link(my_rtph264depay)
my_rtph264depay.link(my_h264parse)
my_h264parse.link(my_splitmuxsink)

my_pipeline.set_state(Gst.State.PLAYING)

try:
GLib.MainLoop().run()
except KeyboardInterrupt:
GLib.MainLoop().quit()



(note: green lines are commented lines which represent something I tried.)

when I run the python script, I go this output:
<class 'gi.repository.Gst.MessageType'>
<Gst.Pipeline object at 0x7f508072e870 (GstPipeline at 0x29e4080)>
<__gi__.GstRTSPSrc object at 0x7f508070fee8 (GstRTSPSrc at 0x29ec820)>
<__gi__.GstRtpH264Depay object at 0x7f508072ee58 (GstRtpH264Depay at 0x291c110)>
<__gi__.GstH264Parse object at 0x7f508072eea0 (GstH264Parse at 0x2a0fa60)>
<__gi__.GstSplitMuxSink object at 0x7f508072eee8 (GstSplitMuxSink at 0x2a18050)>
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STREAM_STATUS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STREAM_STATUS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_PROGRESS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_NEW_CLOCK of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_PROGRESS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_PROGRESS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_STATE_CHANGED of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_PROGRESS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_PROGRESS of type Gst.MessageType> ]]
[[ <flags GST_MESSAGE_ERROR of type Gst.MessageType> ]]
(ERR): gst-resource-error-quark: Could not open resource for reading and writing. (7) gstrtspsrc.c(7465): gst_rtspsrc_
retrieve_sdp (): /GstPipeline:my-pipeline/GstRTSPSrc:rtspsrc:
Failed to connect. (Generic error)


well, I don't understand it. For me the command line and the script do the same thing. Anyone can help me?

regards,
Nicolas J├Ąger

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: porting command line to python

GStreamer-devel mailing list
Need to link  a pad from rtspsrc to rtph264depay
 
Please refer a rtspsrc element and create a new pad.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel