[transmageddon] Improve AAC handling and add ASF support



commit 2e0bf4c5fdab2343617a9b2cd0f6b4c1271ecf1b
Author: Christian Schaller <christian schaller collabora co uk>
Date:   Wed Jul 22 20:09:00 2009 +0100

    Improve AAC handling and add ASF support

 src/codecfinder.py       |   36 ++++++-------------
 src/transcoder_engine.py |    4 +-
 src/transmageddon.glade  |   86 ++++++++++++++++++++++++++++++++++++----------
 src/transmageddon.py     |   32 ++++++++++-------
 4 files changed, 100 insertions(+), 58 deletions(-)
---
diff --git a/src/codecfinder.py b/src/codecfinder.py
index 94a30df..cc900de 100644
--- a/src/codecfinder.py
+++ b/src/codecfinder.py
@@ -35,10 +35,12 @@ def list_compat(a1, b1):
 
 containermap = { 'Ogg' : "application/ogg",'Matroska' : "video/x-matroska", 'MXF' : "application/mxf", 'AVI' : "video/x-msvideo", 
                         'Quicktime' : "video/quicktime,variant=apple", 'MPEG4' : "video/quicktime,variant=iso", 'MPEG PS' : "ffmux_mpeg", 
-                        'MPEG TS' : "video/mpegts", 'FLV' : "video/x-flv", '3GPP' : "video/quicktime,variant=3gpp" }
+                        'MPEG TS' : "video/mpegts", 'FLV' : "video/x-flv", '3GPP' : "video/quicktime,variant=3gpp",
+                        'ASF' : "video/x-ms-asf" }
 
 csuffixmap =   { 'Ogg' : ".ogg", 'Matroska' : ".mkv", 'MXF' : ".mxf", 'AVI' : ".avi", 'Quicktime' : ".mov",
-                        'MPEG4' : ".mp4", 'MPEG PS' : ".mpg", 'MPEG TS' : ".ts", 'FLV' : ".flv", '3GPP' : ".3gp" }
+                        'MPEG4' : ".mp4", 'MPEG PS' : ".mpg", 'MPEG TS' : ".ts", 'FLV' : ".flv", '3GPP' : ".3gp",
+                 'ASF' : ".asf" }
 
 codecmap = {     'vorbis' : "audio/x-vorbis", 'flac' : "audio/x-flac", 'mp3' : "audio/mpeg,mpegversion=1,layer=3", 
                         'aac' : "audio/mpeg,mpegversion=4", 'ac3' : "audio/x-ac3", 'speex' : "audio/x-speex", 
@@ -62,7 +64,7 @@ def get_muxer_element(containercaps):
    """
 
    muxerchoice = {}
-   blacklist = ['rate','packetsize','systemstream']
+   blacklist = ['rate','packetsize','systemstream','parsed']
    flist = gst.registry_get_default().get_feature_list(gst.ElementFactory)
    muxers = []
    features = []
@@ -90,11 +92,10 @@ def get_muxer_element(containercaps):
                muxerchoice[result] = muxer
        else:
            muxerchoice[result] = muxer
-
    if muxerchoice.has_key(containercaps):
        elementname = muxerchoice[containercaps]
    else:
-       print "failed to find element"
+       print "failed to find muxer element"
        elementname = False
    return elementname
 
@@ -135,11 +136,9 @@ def get_audio_encoder_element(audioencodercaps):
                # print "result before attributes " + str(result)
                for attr in caps[0].keys():
                    if attr not in blacklist:
-                       if codec == "faac":
-                           result = "audio/mpeg,mpegversion=4" 
-                       #ugly workaround for Caps.from_string not handling mpegversion =[2,4]
-                       else:
-                           result += ","+attr+"="+str(caps[0][attr])
+                       result += ","+attr+"="+str(caps[0][attr])
+                       if result == "audio/mpeg,mpegversion=[4, 2]":
+                           result = "audio/mpeg,mpegversion=4"
            if audiocoderchoice.has_key(result):
                    mostrecent = gst.PluginFeature.get_rank(encoderfeature[codec])
                    original = gst.PluginFeature.get_rank(encoderfeature[audiocoderchoice[result]])
@@ -148,8 +147,6 @@ def get_audio_encoder_element(audioencodercaps):
            else:
                    audiocoderchoice[result] = codec
 
-   # print "*** printing audiocodecchoice ***"
-   # print audiocoderchoice
    if audiocoderchoice.has_key(audioencodercaps):
        elementname = audiocoderchoice[audioencodercaps]
    else:
@@ -189,37 +186,26 @@ def get_video_encoder_element(videoencodercaps):
    # print encoderfeature
    for x in encoders:
            element = x
-           # print "encoder is " + str(codec)
            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]
            for caps in sinkcaps:
-               # print "caps is "+ str(caps)
                result = caps[0].get_name();
                for attr in caps[0].keys():
                    if attr not in blacklist:
                        result += ","+attr+"="+str(caps[0][attr])
-               # print "result is " + str(result)
-               # print "videocodechoice before if statement"
-               # print videocoderchoice
            if videocoderchoice.has_key(result):
                    mostrecent = gst.PluginFeature.get_rank(encoderfeature[element])
-                   # print "fact is " + str(value)
-                   # print str(codec) + " has rank " + str(mostrecent)
                    original = gst.PluginFeature.get_rank(encoderfeature[videocoderchoice[result]])
-                   # print str(videocoderchoice[result]) + " has rank " + str(original)
-                   # print "original value " + videocoderchoice[result]
                    if mostrecent >= original:
                        videocoderchoice[result] = element
-                       # print "new value " + videocoderchoice[result]
-
            else:
                    videocoderchoice[result] = element
-                   # print videocoderchoice
+
            videocoderchoice["video/x-divx,divxversion=5"] = "ffenc_mpeg4"
-   # print videocoderchoice
    if videocoderchoice.has_key(videoencodercaps):
        elementname = videocoderchoice[videoencodercaps]
    else:
+       print "Failed to find video encoder element"
        elementname = False
    return elementname
 
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index f0d14a2..d0ad8c4 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -134,12 +134,12 @@ class Transcoder(gobject.GObject):
                        if videointersect != ("EMPTY"):
                            # print "pad is X which is " + str(x)
                            self.containermuxervideosinkpad = self.containermuxer.get_request_pad(x.name_template)
-                           # print "self.containermuxervideosinkpad " + str(self.containermuxervideosinkpad)
+                           print "self.containermuxervideosinkpad is " + str(self.containermuxervideosinkpad)
                    if audiointersect == ("EMPTY"):
                        # print "self.audiocaps is " + str(self.audiocaps)
                        # print "caps converted audio caps is " + str(gst.caps_from_string(self.audiocaps))
                        audiointersect = sourcecaps.intersect(gst.caps_from_string(self.audiocaps))
-                       # print "muxer audio intersect is " + str(audiointersect)
+                       print "muxer audio intersect is " + str(audiointersect)
                        if audiointersect != ("EMPTY"):
                            self.containermuxeraudiosinkpad = self.containermuxer.get_request_pad(x.name_template)
                            # print "self.containermuxeraudiosinkpad " + str(self.containermuxeraudiosinkpad)
diff --git a/src/transmageddon.glade b/src/transmageddon.glade
index 73a3c79..b94b776 100644
--- a/src/transmageddon.glade
+++ b/src/transmageddon.glade
@@ -510,15 +510,15 @@
             <child>
               <widget class="GtkTable" id="CodecBox">
                 <property name="visible">True</property>
-                <property name="n_rows">11</property>
+                <property name="n_rows">12</property>
                 <property name="n_columns">3</property>
                 <child>
                   <widget class="GtkLabel" id="label3">
                     <property name="visible">True</property>
                   </widget>
                   <packing>
-                    <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
                   </packing>
                 </child>
                 <child>
@@ -528,19 +528,8 @@
                   <packing>
                     <property name="left_attach">2</property>
                     <property name="right_attach">3</property>
-                    <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
-                  </packing>
-                </child>
-                <child>
-                  <widget class="GtkLabel" id="label12">
-                    <property name="visible">True</property>
-                  </widget>
-                  <packing>
-                    <property name="left_attach">2</property>
-                    <property name="right_attach">3</property>
-                    <property name="top_attach">9</property>
-                    <property name="bottom_attach">10</property>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
                   </packing>
                 </child>
                 <child>
@@ -551,8 +540,8 @@
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
-                    <property name="top_attach">10</property>
-                    <property name="bottom_attach">11</property>
+                    <property name="top_attach">11</property>
+                    <property name="bottom_attach">12</property>
                     <property name="x_options"></property>
                   </packing>
                 </child>
@@ -1022,6 +1011,67 @@
                     <property name="x_options"></property>
                   </packing>
                 </child>
+                <child>
+                  <widget class="GtkRadioButton" id="wma2button">
+                    <property name="label" translatable="yes">WMA2</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="relief">none</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">vorbisbutton</property>
+                    <signal name="pressed" handler="on_wma2button_pressed"/>
+                    <signal name="activate" handler="on_wma2button_pressed"/>
+                  </widget>
+                  <packing>
+                    <property name="top_attach">10</property>
+                    <property name="bottom_attach">11</property>
+                    <property name="y_padding">3</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">10</property>
+                    <property name="bottom_attach">11</property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkLabel" id="vspacer11">
+                    <property name="width_request">12</property>
+                    <property name="visible">True</property>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">10</property>
+                    <property name="bottom_attach">11</property>
+                    <property name="x_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <widget class="GtkRadioButton" id="wmv2button">
+                    <property name="label" translatable="yes">WMV2</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="relief">none</property>
+                    <property name="draw_indicator">True</property>
+                    <property name="group">theorabutton</property>
+                    <signal name="pressed" handler="on_wmv2button_pressed"/>
+                    <signal name="activate" handler="on_wmv2button_pressed"/>
+                  </widget>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">9</property>
+                    <property name="bottom_attach">10</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
                 <property name="position">1</property>
diff --git a/src/transmageddon.py b/src/transmageddon.py
index 3b3d2a1..ca207f6 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -61,7 +61,8 @@ supported_containers = [
         "Quicktime",
         "MPEG4",
         "3GPP",
-        "MXF"
+        "MXF",
+        "ASF"
 ]
 
 supported_audio_codecs = [
@@ -73,9 +74,8 @@ supported_audio_codecs = [
        "ac3",
        "speex",
        "celt",
-       "amrnb"
-#       "alac",
-#       "wma2",
+       "amrnb",
+       "wma2"
 ]
 
 supported_video_codecs = [
@@ -86,7 +86,8 @@ supported_video_codecs = [
        "mpeg2",
        "mpeg4",
        "xvid",
-       "h263p"
+       "h263p",
+       "wmv2"
 ]
 
 # Maps containers to the codecs they support.  The first two elements are
@@ -104,6 +105,7 @@ supported_container_map = {
     'MPEG PS':    [ 'mp3', 'mpeg2', 'ac3', 'h264', 'aac', 'mpeg4' ],
     'MPEG TS':    [ 'mp3', 'h264', 'ac3', 'mpeg2', 'aac', 'mpeg4', 'dirac' ],
     'FLV':        [ 'mp3', 'h264' ],
+    'ASF':        [ 'wma2','wmv2']
 }
 
 class TransmageddonUI (gtk.glade.XML):
@@ -408,10 +410,10 @@ class TransmageddonUI (gtk.glade.XML):
    def check_for_passthrough(self, containerchoice):
        videointersect = ("EMPTY")
        audiointersect = ("EMPTY")
-       print "container is " + str(containerchoice)
+       # print "container is " + str(containerchoice)
        container = codecfinder.containermap[containerchoice]
        containerelement = codecfinder.get_muxer_element(container)
-       print "container element is " + str(containerelement)
+       # print "container element is " + str(containerelement)
        if containerelement == False:
            self.containertoggle = True
            self.check_for_elements()
@@ -422,14 +424,17 @@ class TransmageddonUI (gtk.glade.XML):
                    sourcecaps = x.get_caps()
                    if videointersect == ("EMPTY"):
                        videointersect = sourcecaps.intersect(gst.caps_from_string(self.videodata['videotype']))
+                       print "video intersect is " + str(videointersect)
                        if videointersect != ("EMPTY"):
+                           print "videointersect is not empty"
+                           print "self.vsourcecaps is set to " + str(videointersect)
                            self.vsourcecaps = videointersect
                    if audiointersect == ("EMPTY"):
                        audiointersect = sourcecaps.intersect(gst.caps_from_string(self.audiodata['audiotype']))
                        if audiointersect != ("EMPTY"):
                            self.asourcecaps = audiointersect
-               if videointersect == ("EMPTY"):
-                   self.codec_buttons["vpass"].set_sensitive(False)
+           if videointersect == ("EMPTY"):
+               self.codec_buttons["vpass"].set_sensitive(False)
            else:
                self.codec_buttons["vpass"].set_sensitive(True)
            if audiointersect == ("EMPTY"):
@@ -459,6 +464,7 @@ class TransmageddonUI (gtk.glade.XML):
        if self.videopasstoggle == False:
            videocodec = codecfinder.codecmap[self.VideoCodec]
        else:
+           print "self.vsourcecaps is " + str(self.vsourcecaps)
            videocodec = gst.Caps.to_string(self.vsourcecaps)
        print "audiopass toggle " + str(self.audiopasstoggle)
        if self.audiopasstoggle == False:
@@ -513,7 +519,7 @@ class TransmageddonUI (gtk.glade.XML):
    def check_for_elements(self):
        containerchoice = self.get_widget ("containerchoice").get_active_text ()
        containerstatus = codecfinder.get_muxer_element(codecfinder.containermap[containerchoice])
-       print "containerstatus is " + str(containerstatus)
+       # print "containerstatus is " + str(containerstatus)
        if self.AudioCodec != "apass":
            audiostatus = codecfinder.get_audio_encoder_element(codecfinder.codecmap[self.AudioCodec])
        else: audiostatus = "apass"
@@ -534,11 +540,11 @@ class TransmageddonUI (gtk.glade.XML):
            if videostatus == False:
                fail_info.append(gst.caps_from_string (codecfinder.codecmap[self.VideoCodec]))
            missing = []
-           print "empty missing is " + str(missing)
+           # print "empty missing is " + str(missing)
            for x in fail_info:
                missing.append(gst.pbutils.missing_encoder_installer_detail_new(x))
            context = gst.pbutils.InstallPluginsContext ()
-           print "missing is " + str(missing)
+           # print "missing is " + str(missing)
            strmissing = str(missing)
            gst.pbutils.install_plugins_async (missing, context, self.donemessage, "NULL")
 
@@ -604,7 +610,7 @@ class TransmageddonUI (gtk.glade.XML):
            b.set_sensitive(False)
        for c in codecs:
            self.codec_buttons[c].set_sensitive(True)
-       print "self.AudioCodec before active button is " + str(self.AudioCodec)
+       # print "self.AudioCodec before active button is " + str(self.AudioCodec)
        self.codec_buttons[self.AudioCodec].set_active(True)
        self.codec_buttons[self.VideoCodec].set_active(True)
        self.check_for_passthrough(self.container)



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