# GNU MediaGoblin -- federated, autonomous media hosting
-# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
+# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
from __future__ import division
import os
-os.environ["GST_DEBUG_DUMP_DOT_DIR"] = "/tmp"
os.putenv('GST_DEBUG_DUMP_DOT_DIR', '/tmp')
import sys
import pygst
pygst.require('0.10')
import gst
- from gst import pbutils
from gst.extend import discoverer
except:
raise Exception('gst/pygst 0.10 could not be found')
buffer_probes = {}
- errors = []
-
def __init__(self, source_path, dest_path):
'''
Set up playbin pipeline in order to get video properties.
Initializes and runs the gobject.MainLoop()
'''
+ self.errors = []
+
self.source_path = source_path
self.dest_path = dest_path
self.videosink = gst.element_factory_make('fakesink', 'videosink')
self.playbin.set_property('video-sink', self.videosink)
- #self.audiosink = gst.element_factory_make('fakesink', 'audiosink')
- #self.playbin.set_property('audio-sink', self.audiosink)
+ self.audiosink = gst.element_factory_make('fakesink', 'audiosink')
+ self.playbin.set_property('audio-sink', self.audiosink)
self.bus = self.playbin.get_bus()
self.bus.add_signal_watch()
_log.debug('seek amount: {0}'.format(seek_amount))
-
seek_result = self.thumbnail_pipeline.seek(
1.0,
gst.FORMAT_TIME,
seek_amount,
gst.SEEK_TYPE_NONE,
0)
- '''
-
- seek_result = self.thumbnail_pipeline.seek_simple(
- gst.FORMAT_TIME,
- gst.SEEK_FLAG_FLUSH | gst.SEEK_FLAG_ACCURATE,
- seek_amount)
-
- '''
if not seek_result:
self.errors.append('COULD_NOT_SEEK')
# or audio sink
self.filesrc.link(self.decoder)
- # Link all the video elements in a link to webmux
- self.videoqueue.link(self.videorate)
- self.videorate.link(self.ffmpegcolorspace)
- self.ffmpegcolorspace.link(self.videoscale)
- self.videoscale.link(self.capsfilter)
- #self.capsfilter.link(self.xvimagesink)
- self.capsfilter.link(self.vp8enc)
- self.vp8enc.link(self.webmmux)
+ # Link all the video elements in a row to webmmux
+ gst.element_link_many(
+ self.videoqueue,
+ self.videorate,
+ self.ffmpegcolorspace,
+ self.videoscale,
+ self.capsfilter,
+ self.vp8enc,
+ self.webmmux)
if self.data.is_audio:
- # Link all the audio elements in a line to webmux
- #self.audioconvert.link(self.alsasink)
- self.audioqueue.link(self.audiorate)
- self.audiorate.link(self.audioconvert)
- self.audioconvert.link(self.audiocapsfilter)
- self.audiocapsfilter.link(self.vorbisenc)
- #self.audiocapsfilter.link(self.level)
- #self.level.link(self.vorbisenc)
- self.vorbisenc.link(self.webmmux)
-
- self.webmmux.link(self.progressreport)
- self.progressreport.link(self.filesink)
+ # Link all the audio elements in a row to webmux
+ gst.element_link_many(
+ self.audioqueue,
+ self.audiorate,
+ self.audioconvert,
+ self.audiocapsfilter,
+ self.vorbisenc,
+ self.webmmux)
+
+ gst.element_link_many(
+ self.webmmux,
+ self.progressreport,
+ self.filesink)
# Setup the message bus and connect _on_message to the pipeline
self._setup_bus()
elif t == gst.MESSAGE_ELEMENT:
if message.structure.get_name() == 'progress':
- data = {
- 'structure': message.structure,
- 'percent': message.structure['percent'],
- 'total': message.structure['total'],
- 'current': message.structure['current']}
+ data = dict(message.structure)
if self._progress_callback:
self._progress_callback(data)
_log.info('{percent}% done...'.format(
- percent=data['percent']))
+ percent=data.get('percent')))
_log.debug(data)
elif t == gst.MESSAGE_ERROR: