pygi

vassilux . v.gontcharov at gmail.com
Thu Nov 19 06:53:44 PST 2015


Hi alls,
I try to port my old java-gstreamer application to pygi and make a little
test with follow
This commande works
gst-launch-1.0 filesrc location=c:\\audiotest\\0000ad39.wav ! decodebin !
audioconvert ! audioresample ! lamemp3enc ! filesink
location=c:\\audiotest\\0000ad39.mp3


I want to run something like this from python(pygi)

import logging
from logging.handlers import RotatingFileHandler

logging.basicConfig(level=logging.INFO)

logger = logging.getLogger('myapp')

import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst

GObject.threads_init()
Gst.init(None)

def transcode_process(pathin, pathout):

log_message = "Transcoding %s to %s" % (pathin, pathout)

cmd = 'filesrc location=c:\\\\audiotest\\0000ad39.wav name=source !
decodebin ! audioconvert ! audioresample ! lamemp3enc name=encoder !
filesink location=c:\\\\audiotest\\0000ad39.mp3 name=output'

pipeline = Gst.parse_launch(cmd)

if pipeline == None:
logger.error("Failed get pipeline")
return

source = pipeline.get_by_name('source')

if source == None:
logger.error("Failed get source")
return

try:

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)


pipeline.set_state(Gst.State.NULL)

except Exception as e:
logger.error(str(e))
logger.error("Could not open the file for transcoding. This is probably
happening because there are non-ASCII characters in the filename.")
finally:
try:
# I think this is supposed to free the memory used by the pipeline
pipeline.set_state(Gst.State.NULL)
except:
pass


def main():
print sys.getdefaultencoding()
transcode_process("c:\\\\audiotest\\0000ad39.wav",
"c:\\\\audiotest\\0000ad39.mp3")


if __name__ == "__main__":
main()


Something missing .. :-)

Thank for help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20151119/7da2c56f/attachment.html>


More information about the gstreamer-devel mailing list