[gst-devel] gstreamer-python and playbin

Charles Ulrich charles at bityard.net
Sun Aug 2 02:40:20 CEST 2009


Hi,

I freely admit to still having much to learn about gstreamer (and its
python bindings), but I was wondering if someone can give me any advice
on a simple prototype script I'm working on.

Basically, I'm trying to write a script in Python using gsteamer. The
goal of this script is to capture the data from a uri source and save it
to a file on disk. Because I want to be able to support many types of
sources automatically (file, http, mms, rstp), I thought the playbin
would be the best and simplest way to go. But I'm having a hard time
plugging the filesrc plugin into it.

#!/usr/bin/python

import pygst
pygst.require("0.10")
import gst
import gobject

srcuri='http://r1.scenesat.com:8000/scenesat'
#srcuri='mms://71.127.77.19/wadml'
#srcuri='rtsp://archmp3.wfmu.org/broadcast/wfmu_live.rm'

class Main:
     def __init__(self):
         # Create a pipline object
         self.pipeline = gst.Pipeline("mypipeline")

         # Create the playbin object
         self.streambin = gst.element_factory_make("playbin", "stream")

         # Set the uri property so playbin knows where to fetch from
         self.streambin.set_property('uri', srcuri)

         # Add our playbin to the pipeline
         self.pipeline.add(self.streambin)

         # Create filesink, set location, and configure filesink as playbin
         # audio sink
         self.audiosink = gst.element_factory_make('filesink', 'audiosink')
         self.audiosink.set_property('location', 'foo.dump')
         self.streambin.set_property('audio-sink', self.audiosink)

         # Create fakesink for playbin video sink
         self.videosink = gst.element_factory_make('fakesink', 'videosink')
         self.streambin.set_property('video-sink', self.videosink)

         # Set the pipeline state to playing
         self.pipeline.set_state(gst.STATE_PLAYING)

start=Main()

mainloop = gobject.MainLoop()
mainloop.run()

Basically, what happens is that gstreamer appears to be correctly
fetching the stream and saving _something_ to disk, but what's saved
does not appear to be either audio or video. Mplayer won't play the file
but identifies it as DVSD (video) and ffdv (audio). I thought that 
specifying fakesink for the video sink would make a difference, but it 
does not.

What I'd like to do is construct is a pipeline that can (ideally) detect
the media given to it via some uri and save that media as it is
streamed, without any audio conversion or encoding. Any tips on how I
can accomplish that?

Charles





More information about the gstreamer-devel mailing list