[transmageddon] further cleanups to port
- From: Christian Fredrik Kalager Schaller <uraeus src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [transmageddon] further cleanups to port
- Date: Mon, 7 Feb 2011 13:22:10 +0000 (UTC)
commit 73c68802ccec5e0b33dc5e64ae37c7419b3699c2
Author: Christian Fredrik Kalager Schaller <christian schaller collabora co uk>
Date: Sun Feb 6 17:32:55 2011 +0000
further cleanups to port
src/transcoder_engine_encodebin.py | 233 ++----------------------------------
1 files changed, 9 insertions(+), 224 deletions(-)
---
diff --git a/src/transcoder_engine_encodebin.py b/src/transcoder_engine_encodebin.py
index fb7c05e..7c94783 100644
--- a/src/transcoder_engine_encodebin.py
+++ b/src/transcoder_engine_encodebin.py
@@ -46,8 +46,7 @@ class Transcoder(gobject.GObject):
gobject.GObject.__init__(self)
# Choose plugin based on Container name
- containercaps = codecfinder.containermap[CONTAINERCHOICE]
- self.ContainerFormatPlugin = codecfinder.get_muxer_element(containercaps)
+ self.containercaps = codecfinder.containermap[CONTAINERCHOICE]
# Choose plugin based on Codec Name
# or switch to remuxing mode if any of the values are set to 'pastr'
@@ -59,14 +58,9 @@ class Transcoder(gobject.GObject):
self.videopasstoggle = VIDEOPASSTOGGLE
self.doaudio= False
if self.audiopasstoggle == False:
- # print "audiopasstoggle is false, setting AudioEncoderPlugin"
- # print "self.audiocaps IS **** " + str(self.audiocaps)
self.AudioEncoderPlugin = codecfinder.get_audio_encoder_element(self.audiocaps)
if self.videopasstoggle == False:
- # print "self.videopasstoggle is false so setting self.VideoEncoderPlugin"
- # print "look at incoming videocaps " + str(self.videocaps)
self.VideoEncoderPlugin = codecfinder.get_video_encoder_element(self.videocaps)
- # print "self.VideoEncoderPlugin " + str(self.VideoEncoderPlugin)
self.preset = PRESET
self.oheight = OHEIGHT
self.owidth = OWIDTH
@@ -94,13 +88,13 @@ class Transcoder(gobject.GObject):
self.uridecoder.set_property("uri", FILECHOSEN)
self.uridecoder.connect("pad-added", self.OnDynamicPad)
- self.gstmultiqueue = gst.element_factory_make("multiqueue")
- self.multiqueueaudiosinkpad = self.gstmultiqueue.get_request_pad("sink0")
- self.multiqueuevideosinkpad = self.gstmultiqueue.get_request_pad("sink1")
- self.multiqueueaudiosrcpad = self.gstmultiqueue.get_pad("src0")
- self.multiqueuevideosrcpad = self.gstmultiqueue.get_pad("src1")
+ # self.gstmultiqueue = gst.element_factory_make("multiqueue")
+ # self.multiqueueaudiosinkpad = self.gstmultiqueue.get_request_pad("sink0")
+ # self.multiqueuevideosinkpad = self.gstmultiqueue.get_request_pad("sink1")
+ # self.multiqueueaudiosrcpad = self.gstmultiqueue.get_pad("src0")
+ # self.multiqueuevideosrcpad = self.gstmultiqueue.get_pad("src1")
- self.pipeline.add(self.gstmultiqueue)
+ # self.pipeline.add(self.gstmultiqueue)
self.encodebinprofile = gst.pbutils.EncodingContainerProfile ("ogg", None , gst.Caps("application/ogg"), None)
self.videoprofile = gst.pbutils.EncodingVideoProfile (gst.Caps("video/x-theora"), None, gst.caps_new_any(), 0)
@@ -129,41 +123,11 @@ class Transcoder(gobject.GObject):
self.uridecoder.set_property("caps", self.remuxcaps)
self.pipeline.add(self.uridecoder)
- self.containermuxer = gst.element_factory_make(self.ContainerFormatPlugin, "containermuxer")
- videointersect = ("EMPTY")
- audiointersect = ("EMPTY")
- factory = gst.registry_get_default().lookup_feature(self.ContainerFormatPlugin)
- for x in factory.get_static_pad_templates():
- if (x.direction == gst.PAD_SINK):
- sourcecaps = x.get_caps()
- if videointersect == ("EMPTY"):
- videointersect = sourcecaps.intersect(gst.caps_from_string(self.videocaps))
- if videointersect != ("EMPTY"):
- # print "pad is X which is " + str(x)
- self.containermuxervideosinkpad = self.containermuxer.get_request_pad(x.name_template)
- if audiointersect == ("EMPTY"):
- audiointersect = sourcecaps.intersect(gst.caps_from_string(self.audiocaps))
- if audiointersect != ("EMPTY"):
- self.containermuxeraudiosinkpad = self.containermuxer.get_request_pad(x.name_template)
- self.pipeline.add(self.containermuxer)
-
- # Add a tag setting Transmageddon as the application used for creating file if supported by format
- GstTagSetterType = gobject.type_from_name("GstTagSetter")
- if GstTagSetterType in gobject.type_interfaces(self.containermuxer):
- taglist=gst.TagList()
- taglist[gst.TAG_APPLICATION_NAME] = "Transmageddon"
- self.containermuxer.merge_tags(taglist, gst.TAG_MERGE_APPEND)
-
self.transcodefileoutput = gst.element_factory_make("filesink", "transcodefileoutput")
self.transcodefileoutput.set_property("location", (DESTDIR+"/"+self.outputfilename))
self.pipeline.add(self.transcodefileoutput)
+ self.encodebin.link(self.transcodefileoutput)
- self.transcodefileoutput2 = gst.element_factory_make("filesink", "transcodefileoutput2")
- self.transcodefileoutput2.set_property("location", (DESTDIR+"/"+self.outputfilename+"B"))
- self.pipeline.add(self.transcodefileoutput2)
- self.encodebin.link(self.transcodefileoutput2)
-
- self.containermuxer.link(self.transcodefileoutput)
# print "reached end of first pipeline bulk, next step dynamic audio/video pads"
@@ -193,8 +157,7 @@ class Transcoder(gobject.GObject):
def noMorePads(self, dbin):
if (self.multipass == False) or (self.passcounter == int(0)):
- self.transcodefileoutput2.set_state(gst.STATE_PAUSED)
- self.containermuxer.set_state(gst.STATE_PAUSED)
+ self.transcodefileoutput.set_state(gst.STATE_PAUSED)
glib.idle_add(self.idlePlay)
# print "No More pads received"
@@ -243,184 +206,6 @@ class Transcoder(gobject.GObject):
sinkpad = self.encodebin.emit("request-pad", src_pad.get_caps())
print "action signal returned", sinkpad
src_pad.link(sinkpad)
-
-
-
-
- bob=False
- if bob != False:
- #def OnDynamicPad(self, dbin, sink_pad):
- c = sink_pad.get_caps().to_string()
- if c.startswith("audio/"):
- if self.stoptoggle==True:
- bus = self.pipeline.get_bus()
- bus.post(gst.message_new_application(self.pipeline, gst.Structure('STOP TRANSCODER')))
- #return
- # First check for passthough mode
- if self.audiopasstoggle is False:
- # Check if either we are not doing multipass or if its the final pass before enabling audio
- if (self.multipass == False) or (self.passcounter == int(0)):
- self.audioconverter = gst.element_factory_make("audioconvert")
- self.pipeline.add(self.audioconverter)
- self.audioencoder = gst.element_factory_make(self.AudioEncoderPlugin)
- self.pipeline.add(self.audioencoder)
-
- self.audioresampler = gst.element_factory_make("audioresample")
- self.pipeline.add(self.audioresampler)
- sink_pad.link(self.audioconverter.get_pad("sink"))
-
- self.audioconverter.link(self.audioresampler)
- self.audioresampler.link(self.audioencoder)
-
- self.audioencoder.get_static_pad("src").link(self.multiqueueaudiosinkpad)
- self.audioconverter.set_state(gst.STATE_PAUSED)
- self.audioresampler.set_state(gst.STATE_PAUSED)
- self.audioencoder.set_state(gst.STATE_PAUSED)
- self.gstmultiqueue.set_state(gst.STATE_PAUSED)
- self.multiqueueaudiosrcpad.link(self.containermuxeraudiosinkpad)
-
- else:
- # This code is for handling passthrough mode.
- # TODO: dynamically plug correct parser. Iterate on parsers and intersect.
- # No parser if output is framed
- parsedcaps = gst.caps_from_string(self.audiocaps+",parsed=true")
- framedcaps = gst.caps_from_string(self.audiocaps+",framed=true")
- if (sink_pad.get_caps().is_subset(parsedcaps)) or (sink_pad.get_caps().is_subset(framedcaps)):
- sink_pad.link(self.multiqueueaudiosinkpad)
- self.multiqueueaudiosrcpad.link(self.containermuxeraudiosinkpad)
- self.gstmultiqueue.set_state(gst.STATE_PAUSED)
- else:
- flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
- parsers = []
- self.aparserelement = False
- for fact in flist:
- # print "fact is " + str(fact)
- if self.list_compat(["Codec", "Parser","Audio"], fact.get_klass().split('/')):
- parsers.append(fact.get_name())
- for x in parsers:
- parser = x
- factory = gst.registry_get_default().lookup_feature(str(x))
- sinkcaps = [x.get_caps() for x in factory.get_static_pad_templates() if x.direction == gst.PAD_SRC]
- parseintersect = ("EMPTY")
- for caps in sinkcaps:
- if parseintersect == ("EMPTY"):
- parseintersect = caps.intersect(gst.caps_from_string(self.audiocaps))
- if parseintersect != ("EMPTY"):
- self.aparserelement = parser
- if self.aparserelement == False:
- error_message="noaudioparser"
- self.emit("got-error", error_message)
- self.stoptoggle=True
- # return
- self.audioparse = gst.element_factory_make(self.aparserelement)
- self.pipeline.add(self.audioparse)
-
- # print "audiopad " + str(self.multiqueueaudiosinkpad)
- sink_pad.link(self.audioparse.get_static_pad("sink"))
- self.audioparse.get_static_pad("src").link(self.multiqueueaudiosinkpad)
- self.multiqueueaudiosrcpad.link(self.containermuxeraudiosinkpad)
- self.audioparse.set_state(gst.STATE_PAUSED)
- self.gstmultiqueue.set_state(gst.STATE_PAUSED)
-
- elif c.startswith("video/"):
- if self.stoptoggle==True:
- bus = self.pipeline.get_bus()
- bus.post(gst.message_new_application(self.pipeline, gst.Structure('STOP TRANSCODER')))
- #return
- if self.videopasstoggle == False:
- # print "Got an video cap"
- self.colorspaceconverter = gst.element_factory_make("ffmpegcolorspace")
- self.pipeline.add(self.colorspaceconverter)
- # checking for deinterlacer
- if self.interlaced == True:
- self.deinterlacer = gst.element_factory_make("deinterlace", "deinterlacer")
- self.pipeline.add(self.deinterlacer)
- self.videoflipper = gst.element_factory_make("videoflip")
- self.videoflipper.set_property("method", self.rotationvalue)
- self.pipeline.add(self.videoflipper)
-
- self.vcaps2 = gst.Caps()
- self.vcaps2 = gst.caps_from_string(self.videocaps)
- if self.preset != "nopreset":
- height, width, num, denom, pixelaspectratio = self.provide_presets()
- for vcap in self.vcaps2:
- if pixelaspectratio != gst.Fraction(0, 0):
- vcap["pixel-aspect-ratio"] = pixelaspectratio
- self.vcapsfilter2 = gst.element_factory_make("capsfilter")
- self.vcapsfilter2.set_property("caps", self.vcaps2)
- self.pipeline.add(self.vcapsfilter2)
-
-
- self.videoencoder = gst.element_factory_make(self.VideoEncoderPlugin)
- self.pipeline.add(self.videoencoder)
-
- # check if interlaced
- if self.interlaced:
- sink_pad.link(self.deinterlacer.get_pad("sink"))
- self.deinterlacer.link(self.videoflipper)
- self.videoflipper.link(self.colorspaceconverter)
- self.colorspaceconverter.link(self.videoencoder)
- else:
- sink_pad.link(self.colorspaceconverter.get_pad("sink"))
- self.colorspaceconverter.link(self.videoflipper)
- self.videoflipper.link(self.videoencoder)
-
- self.videoencoder.link(self.vcapsfilter2)
- self.vcapsfilter2.get_static_pad("src").link(self.multiqueuevideosinkpad)
-
- self.colorspaceconverter.set_state(gst.STATE_PAUSED)
- if self.interlaced:
- self.deinterlacer.set_state(gst.STATE_PAUSED)
- self.videoflipper.set_state(gst.STATE_PAUSED)
-
- self.vcapsfilter2.set_state(gst.STATE_PAUSED)
- self.videoencoder.set_state(gst.STATE_PAUSED)
- self.gstmultiqueue.set_state(gst.STATE_PAUSED)
- self.multiqueuevideosrcpad.link(self.containermuxervideosinkpad)
- else:
- # Code for passthrough mode
- vparsedcaps = gst.caps_from_string(self.videocaps+",parsed=true")
- vframedcaps = gst.caps_from_string(self.videocaps+",framed=true")
- if (sink_pad.get_caps().is_subset(vparsedcaps)) or (sink_pad.get_caps().is_subset(vframedcaps)):
- sink_pad.link(self.multiqueuevideosinkpad)
- self.multiqueuevideosrcpad.link(self.containermuxervideosinkpad)
- self.gstmultiqueue.set_state(gst.STATE_PAUSED)
- else:
- flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
- parsers = []
- self.vparserelement = False
- for fact in flist:
- if self.list_compat(["Codec", "Parser","Video"], fact.get_klass().split('/')):
- parsers.append(fact.get_name())
- elif self.list_compat(["Codec", "Parser"], fact.get_klass().split('/')):
- parsers.append(fact.get_name())
- for x in parsers:
- parser = x
- factory = gst.registry_get_default().lookup_feature(str(x))
- sinkcaps = [x.get_caps() for x in factory.get_static_pad_templates() if x.direction == gst.PAD_SRC]
- parseintersect = ("EMPTY")
- for caps in sinkcaps:
- if parseintersect == ("EMPTY"):
- parseintersect = caps.intersect(gst.caps_from_string(self.videocaps))
- if parseintersect != ("EMPTY"):
- self.vparserelement = parser
- if self.vparserelement == False:
- error_message="novideoparser"
- self.emit("got-error", error_message)
- self.stoptoggle=True
- #return
-
-
- self.videoparse = gst.element_factory_make(self.vparserelement)
- self.pipeline.add(self.videoparse)
- sink_pad.link(self.videoparse.get_static_pad("sink"))
- self.videoparse.get_static_pad("src").link(self.multiqueuevideosinkpad)
- self.videoparse.set_state(gst.STATE_PAUSED)
- self.multiqueuevideosrcpad.link(self.containermuxervideosinkpad)
- self.gstmultiqueue.set_state(gst.STATE_PAUSED)
- else:
- raise Exception("Got a non-A/V pad!")
- # print "Got a non-A/V pad!"
def Pipeline (self, state):
if state == ("playing"):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]