[transmageddon] A slew of fixes and improvements, can now deal with choosing a second file :)



commit 2a5049cfe804dd2e6c14b00171bdc6288f2ddcbc
Author: Christian Fredrik Kalager Schaller <christian schaller collabora co uk>
Date:   Thu Sep 29 19:01:46 2011 +0100

    A slew of fixes and improvements, can now deal with choosing a second file :)

 src/transcoder_engine.py |   28 +++++++++++++++++++-----
 src/transmageddon.py     |   51 ++++++++++++++++++++++++++++------------------
 2 files changed, 53 insertions(+), 26 deletions(-)
---
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index 6797c96..5851055 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -116,6 +116,16 @@ class Transcoder(gobject.GObject):
        self.uridecoder.connect("pad-added", self.OnDynamicPad)
 
        # first check if we have a container format, if not set up output for possible outputs
+       #  should not be hardcoded
+
+       audiopreset=None
+       videopreset=None
+       # if self.preset != "nopreset": 
+           # print "got preset and will use Quality Normal"
+           # these values should not be hardcoded, but gotten from profile XML file
+           # audiopreset="Quality Normal"
+           #videopreset="Quality Normal"
+
        if self.container==False:
            if self.audiocaps.intersect(gst.Caps("audio/mpeg, mpegversion=4")):
                self.audiocaps=gst.Caps("audio/mpeg, mpegversion=4, stream-format=adts")
@@ -125,13 +135,13 @@ class Transcoder(gobject.GObject):
            self.encodebinprofile = gst.pbutils.EncodingContainerProfile ("containerformat", None , self.containercaps, None)
        if self.audiocaps != False:
            if self.container==False:
-               self.encodebinprofile = gst.pbutils.EncodingAudioProfile (self.audiocaps, "Quality Normal", gst.caps_new_any(), 0)
+               self.encodebinprofile = gst.pbutils.EncodingAudioProfile (gst.Caps(self.audiocaps), audiopreset, gst.caps_new_any(), 0)
            else:
-               self.audioprofile = gst.pbutils.EncodingAudioProfile (self.audiocaps, "Quality Normal", gst.caps_new_any(), 0)
+               self.audioprofile = gst.pbutils.EncodingAudioProfile (gst.Caps(self.audiocaps), audiopreset, gst.caps_new_any(), 0)
                self.encodebinprofile.add_profile(self.audioprofile)
        if self.videocaps != "novid":
            if (self.videocaps != False):
-               self.videoprofile = gst.pbutils.EncodingVideoProfile (gst.Caps(self.videocaps), "Quality Normal", gst.caps_new_any(), 0)
+               self.videoprofile = gst.pbutils.EncodingVideoProfile (gst.Caps(self.videocaps), videopreset, gst.caps_new_any(), 0)
                self.encodebinprofile.add_profile(self.videoprofile)
        self.encodebin = gst.element_factory_make ("encodebin", None)
        self.encodebin.set_property("profile", self.encodebinprofile)
@@ -341,7 +351,7 @@ class Transcoder(gobject.GObject):
    def OnDynamicPad(self, uridecodebin, src_pad):
        origin = src_pad.get_caps()
        if (self.container==False):
-           a =  src_pad.get_caps().to_string()
+           a =  origin.get_caps().to_string()
            if a.startswith("audio/"):
                sinkpad = self.encodebin.get_static_pad("audio_0")
                src_pad.link(sinkpad)
@@ -365,13 +375,19 @@ class Transcoder(gobject.GObject):
                        self.videoflipper.get_static_pad("src").link(sinkpad)
                        
                    else:
+                       srccaps=src_pad.get_caps()
+                       srcstring=srccaps.to_string()
+                       #print "source pad is " + str(srcstring)
+                       sinkcaps=sinkpad.get_caps()
+                       sinkstring=sinkcaps.to_string()
+                       #print "sinkpad is " + str(sinkstring)
                        src_pad.link(sinkpad)
 
-       # Grab element from encodebin which supports tagsetter interface and set app name to Transmageddon
+       # Grab element from encodebin which supports tagsetter interface and set app name
+       # to Transmageddon
        GstTagSetterType = gobject.type_from_name("GstTagSetter")
        tag_setting_element=self.encodebin.get_by_interface(GstTagSetterType)
        if tag_setting_element != None:
-           print "tag setting element is " + str(tag_setting_element)	
            taglist=gst.TagList()
            taglist[gst.TAG_APPLICATION_NAME] = "Transmageddon transcoder"
            tag_setting_element.merge_tags(taglist, gst.TAG_MERGE_APPEND)
diff --git a/src/transmageddon.py b/src/transmageddon.py
index a902b83..cb8c714 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -59,20 +59,20 @@ TARGET_TYPE_URI_LIST = 80
 dnd_list = [ ( 'text/uri-list', 0, TARGET_TYPE_URI_LIST ) ]
 
 supported_containers = [
-        "Ogg",
-        "Matroska",
-        "AVI",
-        "MPEG PS",
-        "MPEG TS",
-        "AVCHD/BD",
-        "FLV",
-        "Quicktime",
-        "MPEG4",
-        "3GPP",
-        "MXF",
-        "ASF", 
+        "Ogg",		#0
+        "Matroska",	#1
+        "AVI",		#2
+        "MPEG PS",	#3
+        "MPEG TS",	#4
+        "AVCHD/BD",	#5
+        "FLV",		#6
+        "Quicktime",	#7
+        "MPEG4",	#8
+        "3GPP",		#9
+        "MXF",		#10
+        "ASF", 		#11
         "I can not get this item to show for some reason",
-        "WebM"
+        "WebM"		#12
 ]
 
 supported_audio_codecs = [
@@ -165,7 +165,9 @@ class TransmageddonUI:
        self.videorows=[]
        self.audiocodecs=[] # create lists to store the ordered lists of codecs
        self.videocodecs=[]
-
+	
+       # set flag so we remove bogus value from menu only once
+       self.bogus=0
 
        # these dynamic comboboxes allow us to support files with multiple streams eventually
        def dynamic_comboboxes_audio(streams,extra = []):
@@ -429,22 +431,26 @@ class TransmageddonUI:
        try:
            position, format = \
                    self._transcoder.uridecoder.query_position(gst.FORMAT_TIME)
+           # print "position is " + str(position)
        except:
            position = gst.CLOCK_TIME_NONE
 
        try:
            duration, format = \
                    self._transcoder.uridecoder.query_duration(gst.FORMAT_TIME)
+           # print "duration is " + str(duration)
        except:
            duration = gst.CLOCK_TIME_NONE
        if position != gst.CLOCK_TIME_NONE:
            value = float(position) / duration
+           # print "value is " + str(value)
            if float(value) < (1.0) and float(value) >= 0:
                self.ProgressBar.set_fraction(value)
                percent = (value*100)
                timespent = time.time() - self.start_time
                percent_remain = (100-percent)
-               # print percent_remain
+               # print "percent remain " + str(percent_remain)
+               # print "percentage is " + str(percent)
                if percent != 0:
                    rem = (timespent / percent) * percent_remain
                else: 
@@ -470,6 +476,7 @@ class TransmageddonUI:
                self.ProgressBar.set_fraction(0.0)
                return False
        else:
+           print "complete progress measuering failure"
            return False
 
    # Call gobject.timeout_add with a value of 500millisecond to regularly poll
@@ -539,7 +546,6 @@ class TransmageddonUI:
        markupaudioinfo=[]
        videowidth = None
        videoheight = None
-
        for i in info.get_stream_list():
            if isinstance(i, gst.pbutils.DiscovererAudioInfo):
                audiostreamcounter=audiostreamcounter+1
@@ -558,7 +564,6 @@ class TransmageddonUI:
 
                self.containerchoice.set_active(-1) # set this here to ensure it happens even with quick audio-only
                self.containerchoice.set_active(0)
-
            if self.haveaudio==False:
                self.audioinformation.set_markup(''.join(('<small>', _("No Audio"), '</small>')))
                self.audiocodec.set_markup(''.join(('<small>', "",'</small>')))
@@ -665,6 +670,8 @@ class TransmageddonUI:
        self.filename = self.builder.get_object ("FileChooser").get_filename()
        self.audiodata = {}
        if self.filename is not None: 
+           self.haveaudio=False #make sure to reset these for each file
+           self.havevideo=False #
            self.mediacheck(self.filename)
            self.ProgressBar.set_fraction(0.0)
            self.ProgressBar.set_text(_("Transcoding Progress"))
@@ -673,7 +680,11 @@ class TransmageddonUI:
            else:
                self.presetchoice.set_sensitive(True)
                self.presetchoice.set_active(0)
-               self.containerchoice.remove_text(12)
+
+               # removing bogus text from supported_containers
+               if self.bogus==0:
+                   self.containerchoice.remove_text(12)
+                   self.bogus=1
                self.nocontaineroptiontoggle=False
            self.containerchoice.set_sensitive(True)
 
@@ -791,9 +802,9 @@ class TransmageddonUI:
            if containerstatus == False: 
                fail_info.append(gst.caps_from_string(codecfinder.containermap[containerchoice]))
            if audiostatus == False:
-               fail_info.append(gst.caps_from_string(self.AudioCodec))
+               fail_info.append(self.AudioCodec)
            if videostatus == False:
-               fail_info.append(gst.caps_from_string (self.VideoCodec))
+               fail_info.append(self.VideoCodec)
            missing = []
            for x in fail_info:
                missing.append(gst.pbutils.missing_encoder_installer_detail_new(x))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]