[transmageddon/gtk3] Add various fixes and cleanups
- From: Christian Fredrik Kalager Schaller <uraeus src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [transmageddon/gtk3] Add various fixes and cleanups
- Date: Wed, 25 Jan 2012 14:55:16 +0000 (UTC)
commit 5e628d710a948eb187c095a22b7a6b663b9298ed
Author: Christian Fredrik Kalager Schaller <christian schaller collabora co uk>
Date: Wed Jan 25 14:54:59 2012 +0000
Add various fixes and cleanups
src/codecfinder.py | 2 +-
src/transcoder_engine.py | 29 ++++++++-------
src/transmageddon.py | 87 +++++++++++++--------------------------------
3 files changed, 41 insertions(+), 77 deletions(-)
---
diff --git a/src/codecfinder.py b/src/codecfinder.py
index b1d022b..6180ca0 100644
--- a/src/codecfinder.py
+++ b/src/codecfinder.py
@@ -136,7 +136,7 @@ def get_muxer_element(containercaps):
features.append(fact)
muxerfeature = dict(zip(muxers, features))
incomingcaps = Gst.caps_from_string(containercaps)
- print "incomingcaps is " + str(containercaps)
+ # print "incomingcaps is " + str(containercaps)
for muxer in muxers:
element = muxer
factory = Gst.Registry.get().lookup_feature(str(muxer))
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index ebf57ac..e11cf7c 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -42,9 +42,11 @@ class Transcoder(GObject.GObject):
# Choose plugin based on Container name
self.container = CONTAINERCHOICE
+ print "self.container is"
self.audiocaps = AUDIOCODECVALUE
if self.container != False:
self.containercaps = Gst.caps_from_string(codecfinder.containermap[CONTAINERCHOICE])
+ print "self.containercaps"
# special case mp3 which is a no-container format with a container (id3mux)
else:
if self.audiocaps.intersect(Gst.caps_from_string("audio/mpeg, mpegversion=1, layer=3")):
@@ -126,12 +128,12 @@ class Transcoder(GObject.GObject):
if self.videopasstoggle==False:
if self.container != False:
self.videoflipper = Gst.ElementFactory.make('videoflip', None)
- print "videoflipper created " + str(self.videoflipper)
+ # print "videoflipper created " + str(self.videoflipper)
self.videoflipper.set_property("method", self.rotationvalue)
self.pipeline.add(self.videoflipper)
self.colorspaceconverter = Gst.ElementFactory.make("videoconvert", None)
- print "creating colorspaceconverter " + str(self.colorspaceconverter)
+ # print "creating colorspaceconverter " + str(self.colorspaceconverter)
self.pipeline.add(self.colorspaceconverter)
#self.deinterlacer = Gst.ElementFactory.make('deinterlace', None)
@@ -143,14 +145,13 @@ class Transcoder(GObject.GObject):
self.colorspaceconverter.set_state(Gst.State.PAUSED)
self.videoflipper.set_state(Gst.State.PAUSED)
- print "self.containercaps is " +str(self.containercaps)
- self.encodebinprofile = GstPbutils.EncodingContainerProfile.new("containerformat", None , self.containercaps, None)
- print "self.encodebinprofile is " + str(self.encodebinprofile)
+ # print "self.containercaps is " +str(self.containercaps)
+ self.encodebinprofile = GstPbutils.EncodingContainerProfile.new("containerformat", None , self.containercaps, None)
if self.audiocaps != False:
if self.container==False:
self.encodebinprofile = GstPbutils.EncodingAudioProfile.new (self.audiocaps, audiopreset, Gst.Caps.new_any(), 0)
else:
- print "self.audiocaps is " + str(self.audiocaps)
+ # print "self.audiocaps is " + str(self.audiocaps)
audiopreset=None
self.audioprofile = GstPbutils.EncodingAudioProfile.new(self.audiocaps, audiopreset, Gst.Caps.new_any(), 0)
self.encodebinprofile.add_profile(self.audioprofile)
@@ -163,7 +164,7 @@ class Transcoder(GObject.GObject):
self.encodebin.set_property("profile", self.encodebinprofile)
self.encodebin.set_property("avoid-reencoding", True)
self.pipeline.add(self.encodebin)
- print "creating encodebin " +str(self.encodebin)
+ # print "creating encodebin " +str(self.encodebin)
self.encodebin.set_state(Gst.State.PAUSED)
self.remuxcaps = Gst.Caps()
@@ -188,8 +189,8 @@ class Transcoder(GObject.GObject):
self.uridecoder.set_property("caps", self.remuxcaps)
self.uridecoder = Gst.ElementFactory.make("uridecodebin", "uridecoder")
- print "self.uridecoder " + str(self.uridecoder)
- print "FILECHOSEN " + str(FILECHOSEN)
+ # print "self.uridecoder " + str(self.uridecoder)
+ # print "FILECHOSEN " + str(FILECHOSEN)
self.uridecoder.set_property("uri", FILECHOSEN)
self.uridecoder.connect("pad-added", self.OnDynamicPad)
self.uridecoder.set_state(Gst.State.PAUSED)
@@ -333,7 +334,7 @@ class Transcoder(GObject.GObject):
return True
def OnDynamicPad(self, uridecodebin, src_pad):
- print "src_pad is" +str(src_pad)
+ # print "src_pad is" +str(src_pad)
origin = src_pad.query_caps(None)
if (self.container==False):
a = origin.to_string()
@@ -356,16 +357,16 @@ class Transcoder(GObject.GObject):
c = origin.to_string()
if not c.startswith("text/"):
if not (c.startswith("video/") and (self.videocaps == False)):
- print "origin is " + str(c)
+ # print "origin is " + str(c)
sinkpad = self.encodebin.emit("request-pad", origin)
if c.startswith("audio/"):
- print "src_pad is " +str(src_pad)
- print "sinkpad is " +str(sinkpad)
+ # print "src_pad is " +str(src_pad)
+ # print "sinkpad is " +str(sinkpad)
src_pad.link(sinkpad)
elif ((c.startswith("video/") or c.startswith("image/")) and (self.videocaps != False)):
if self.videopasstoggle==False:
# port fix- should be self.deinterlacer
- print "self.colorspaceconverter before use " + str(self.colorspaceconverter)
+ # print "self.colorspaceconverter before use " + str(self.colorspaceconverter)
colorspacepad = self.colorspaceconverter.get_static_pad("sink")
src_pad.link(colorspacepad)
self.videoflipper.get_static_pad("src").link(sinkpad)
diff --git a/src/transmageddon.py b/src/transmageddon.py
index 1c8a14c..c4c3af8 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -218,6 +218,7 @@ class TransmageddonUI:
self.CodecBox.attach(self.audiobox, 0, 1, 1, 2, yoptions = Gtk.AttachOptions.FILL)
self.CodecBox.attach(self.videobox, 2, 3, 1, 2, yoptions = Gtk.AttachOptions.FILL)
self.CodecBox.show_all()
+ self.containerchoice.connect("changed", self.on_containerchoice_changed)
self.audiorows[0].connect("changed", self.on_audiocodec_changed)
self.videorows[0].connect("changed", self.on_videocodec_changed)
self.TopWindow.connect("destroy", Gtk.main_quit)
@@ -623,9 +624,8 @@ class TransmageddonUI:
def check_for_passthrough(self, containerchoice):
videointersect = Gst.Caps.new_empty()
audiointersect = Gst.Caps.new_empty()
- if (containerchoice != False or self.usingpreset==False):
+ if containerchoice != False: # or self.usingpreset==False): <- Need to figure out what this was about
container = codecfinder.containermap[containerchoice]
- print "container is " + str(container)
containerelement = codecfinder.get_muxer_element(container)
if containerelement == False:
self.containertoggle = True
@@ -636,30 +636,27 @@ class TransmageddonUI:
sourcecaps = x.get_caps()
if self.havevideo == True:
if Gst.Caps.is_empty(videointersect):
- print "intersect is EMPTY"
videointersect = sourcecaps.intersect(self.videodata['videotype'])
- output=Gst.Caps.to_string(videointersect)
- print "videointersect is empty " + str(output)
else:
if self.vsourcecaps != False:
- output2 = Gst.Caps.to_string(self.vsourcecaps)
- print "intersect is not empty " + (str(output2))
self.vsourcecaps = videointersect
if self.haveaudio == True:
- if audiointersect == Gst.Caps.new_empty():
+ if audiointersect.is_empty():
audiointersect = sourcecaps.intersect(self.audiodata['audiotype'])
- if audiointersect != Gst.Caps.new_empty():
- self.asourcecaps = audiointersect
- if videointersect.is_empty:
+ else:
+ self.asourcecaps = audiointersect
+ output3 = Gst.Caps.to_string(videointersect)
+ print "output is " + str(output3)
+ # test=videointersect.is_empty()
+ if videointersect.is_empty():
+ print "is empty"
self.videopass=False
else:
+ print "got caps"
output3 = Gst.Caps.to_string(videointersect)
- print "videointersect3 is " + str(output3)
+ print "output is " + str(output3)
self.videopass=True
- print "videopass is " + str(self.videopass)
-
-
- if audiointersect.is_empty:
+ if audiointersect.is_empty():
self.audiopass=False
else:
self.audiopass=True
@@ -697,13 +694,13 @@ class TransmageddonUI:
vwidth = self.videodata['videowidth']
ratenum = self.videodata['fratenum']
ratednom = self.videodata['frateden']
- if self.videopasstoggle == False:
- videocodec = self.VideoCodec
- else: # this is probably redundant and caused by encodebin
- textdata=Gst.Caps.to_string(self.vsourcecaps)
- sep= ','
- minitext = textdata.split(sep, 1)[0]
- videocodec = minitext
+ #if self.videopasstoggle == False:
+ videocodec = self.VideoCodec
+ #else: # this is probably redundant and caused by encodebin
+ # textdata=Gst.Caps.to_string(self.vsourcecaps)
+ # sep= ','
+ # minitext = textdata.split(sep, 1)[0]
+ #videocodec = minitext
self.outputdirectory=self.videodirectory
else:
self.outputdirectory=self.audiodirectory
@@ -722,8 +719,6 @@ class TransmageddonUI:
audiocodec=False
achannels=False
- # print "transcoder values - filechoice: " + str(filechoice) + " - filename: " + str(self.filename) + " - outputdirectory: " + str(self.outputdirectory) + " - self.container: " + str(self.container) + " - audiocodec: " + str(audiocodec) + " - videocodec: " + str(videocodec), " -self.devicename: " + str(self.devicename) + "- vheight:" + str(vheight), " - vwidth: " + str(vwidth) + " - achannels: " + str(achannels) + " - self.multipass " + str(self.multipass) + " - self.passcounter: " + str(self.passcounter) + " -self.outputfilename: " + str(self.outputfilename) + " - self.timestamp: " + str(self.timestamp) + " - self.rotationvalue: " + str(self.rotationvalue) + " - self.audiopasstoggle: " + str(self.audiopasstoggle) + " - self.videopasstoggle: " + str(self.videopasstoggle) + " - self.interlaced: " + str(self.interlaced) + " - self.inputvideocaps: " + str(self.inputvideocaps)
-
self._transcoder = transcoder_engine.Transcoder(filechoice, self.filename,
self.outputdirectory, self.container, audiocodec,
videocodec, self.devicename,
@@ -781,49 +776,21 @@ class TransmageddonUI:
containerstatus=True
videostatus=True
else:
- # print "checking for elements"
containerchoice = self.builder.get_object ("containerchoice").get_active_text()
- #print "containerchoise is " + str(containerchoice)
if containerchoice != None:
containerstatus = codecfinder.get_muxer_element(codecfinder.containermap[containerchoice])
- #print "containerchoice returned is " +str(containerstatus)
- #if self.havevideo:
- # if self.videopasstoggle != True:
- # if self.VideoCodec == "novid":
- # videostatus=True
- # else:
- # videostatus = codecfinder.get_video_encoder_element(self.VideoCodec)
- # else:
- # videostatus=True
- #if self.haveaudio:
- # if self.audiopasstoggle != True:
- # audiostatus = codecfinder.get_audio_encoder_element(self.AudioCodec)
- # else:
- # audiostatus=True
- #else:
- # audiostatus=True
- #if self.havevideo == False: # this flags help check if input is audio-only file
- # videostatus=True
- # print "containerstatus is here " + str(containerstatus)
+
if not containerstatus: # or not videostatus or not audiostatus:
self.missingtoggle=True
fail_info = []
- #if self.containertoggle==True:
- # audiostatus=True
- # videostatus=True
if containerstatus == False:
fail_info.append(Gst.caps_from_string(codecfinder.containermap[containerchoice]))
- #if audiostatus == False:
- # fail_info.append(self.AudioCodec)
- #if videostatus == False:
- # fail_info.append(self.VideoCodec)
missing = []
for x in fail_info:
missing.append(GstPbutils.missing_encoder_installer_detail_new(x))
context = GstPbutils.InstallPluginsContext ()
context.set_xid(self.TopWindow.get_window().get_xid())
strmissing = str(missing)
- # print "strmissing is " + strmissing
GstPbutils.install_plugins_async (strmissing, context, \
self.donemessage, "NULL")
@@ -903,11 +870,8 @@ class TransmageddonUI:
for c in self.audiocodecs: #
self.audiorows[0].remove(0)
self.audiocodecs =[]
- # print "checking for video"
if self.havevideo==True:
- # print "found video"
if self.container != False:
- # print "found conntainer"
for c in self.videocodecs:
self.videorows[0].remove(0)
self.videocodecs=[]
@@ -930,7 +894,6 @@ class TransmageddonUI:
self.audiorows[0].set_active(0)
self.audiorows[0].set_sensitive(True)
else:
- # print "getting to where audio options are filled inn"
audio_codecs = []
audio_codecs = supported_audio_container_map[self.container]
for c in audio_codecs:
@@ -977,8 +940,6 @@ class TransmageddonUI:
self.audiopassmenuno=(len(self.audiocodecs))-1
def on_containerchoice_changed(self, widget):
- self.check_for_elements()
- self.populate_menu_choices()
self.CodecBox.set_sensitive(True)
self.ProgressBar.set_fraction(0.0)
self.ProgressBar.set_text(_("Transcoding Progress"))
@@ -990,9 +951,11 @@ class TransmageddonUI:
else:
if self.builder.get_object("containerchoice").get_active()!= -1:
self.container = self.builder.get_object ("containerchoice").get_active_text()
+ self.check_for_elements()
# print "self.container is " + str(self.container)
- if self.discover_done == True:
- self.check_for_passthrough(self.container)
+ if self.discover_done == True:
+ self.check_for_passthrough(self.container)
+ self.populate_menu_choices()
self.transcodebutton.set_sensitive(True)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]