[transmageddon] Collection of smaller changes * Add some basic tag setting * futher preparation for multi audio stre



commit 74387677fa8024c0e1f7476d54a6b4024f35075e
Author: Christian Fredrik Kalager Schaller <christian schaller collabora co uk>
Date:   Mon Jul 25 15:11:20 2011 +0100

    Collection of smaller changes
    * Add some basic tag setting
    * futher preparation for multi audio stream support
    * check to avoid transcoding/remuxing hanging due to subtitle streams

 src/transcoder_engine.py |   24 ++++++++++++----
 src/transmageddon.py     |   70 ++++++++++++++++++++++++++++++----------------
 2 files changed, 64 insertions(+), 30 deletions(-)
---
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index 0fed726..c71c42e 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -138,6 +138,16 @@ class Transcoder(gobject.GObject):
        self.encodebin.set_property("avoid-reencoding", True)
        self.pipeline.add(self.encodebin)
        self.encodebin.set_state(gst.STATE_PAUSED)
+
+       # 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:
+           taglist=gst.TagList()
+           taglist[gst.TAG_APPLICATION_NAME] = "Transmageddon transcoder"
+           tag_setting_element.merge_tags(taglist, gst.TAG_MERGE_APPEND)
+
+
        if self.videopasstoggle==False:
            if self.container != False:
                self.videoflipper = gst.element_factory_make("videoflip")
@@ -337,6 +347,7 @@ class Transcoder(gobject.GObject):
        return True
 
    def OnDynamicPad(self, uridecodebin, src_pad):
+       origin = src_pad.get_caps()
        if (self.container==False):
            a =  src_pad.get_caps().to_string()
            if a.startswith("audio/"):
@@ -344,15 +355,16 @@ class Transcoder(gobject.GObject):
                src_pad.link(sinkpad)
        else:
            if self.videocaps == "novid":
-               a =  src_pad.get_caps().to_string()
+               c = origin.to_string()
                if a.startswith("audio/"):
-                   sinkpad = self.encodebin.emit("request-pad", src_pad.get_caps())
-                   c = sinkpad.get_caps().to_string()
-                   if c.startswith("audio/"):
+                   sinkpad = self.encodebin.emit("request-pad", origin)
+                   d = sinkpad.get_caps().to_string()
+                   if d.startswith("audio/"):
                        src_pad.link(sinkpad)
            else:
-               sinkpad = self.encodebin.emit("request-pad", src_pad.get_caps())
-               c = sinkpad.get_caps().to_string()
+               c = origin.to_string()
+               if not c.startswith("text/"):
+                   sinkpad = self.encodebin.emit("request-pad", origin)
                if c.startswith("audio/"):
                    src_pad.link(sinkpad)
                elif c.startswith("video/"):
diff --git a/src/transmageddon.py b/src/transmageddon.py
index e77eb2d..2b30c63 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -532,24 +532,28 @@ class TransmageddonUI:
 
        audiostreamcounter=-1
        audiostreams=[]
+       audiotags=[]
+       audiochannels=[]
+       samplerate=[]
+       inputaudiocaps=[]
+       markupaudioinfo=[]
+
        for i in info.get_stream_list():
-           audiostreamcounter=audiostreamcounter+1
            if isinstance(i, gst.pbutils.DiscovererAudioInfo):
-               inputaudiocaps=i.get_caps()
+               audiostreamcounter=audiostreamcounter+1
+               inputaudiocaps.append(i.get_caps())
                audiostreams.append( \
-                       gst.pbutils.get_codec_description(inputaudiocaps))
-               audiotags=i.get_tags()
-               audiochannels=i.get_channels()
-               samplerate=i.get_sample_rate()
+                       gst.pbutils.get_codec_description(inputaudiocaps[audiostreamcounter]))
+               audiotags.append(i.get_tags())
+               audiochannels.append(i.get_channels())
+               samplerate.append(i.get_sample_rate())
                self.haveaudio=True
-               self.audiodata = { 'audiochannels' : audiochannels, \
-                       'samplerate' : samplerate, 'audiotype' : inputaudiocaps, \
+               self.audiodata = { 'audiochannels' : audiochannels[audiostreamcounter], \
+                       'samplerate' : samplerate[audiostreamcounter], 'audiotype' : inputaudiocaps[audiostreamcounter], \
                        'clipduration' : clipduration }
-               self.audioinformation.set_markup(''.join(('<small>', \
-                       'Audio channels: ', str(audiochannels) ,'</small>')))
-               self.audiocodec.set_markup(''.join(('<small>','Audio codec: ', \
-                       str(gst.pbutils.get_codec_description(inputaudiocaps)), \
-                       '</small>')))
+               markupaudioinfo.append((''.join(('<small>', \
+                       'Audio channels: ', str(audiochannels[audiostreamcounter]) ,'</small>'))))
+
                self.containerchoice.set_active(-1) # set this here to ensure it happens even with quick audio-only
                self.containerchoice.set_active(0)
 
@@ -572,11 +576,7 @@ class TransmageddonUI:
 
                self.videodata = { 'videowidth' : videowidth, 'videoheight' : videoheight, 'videotype' : self.inputvideocaps,
                               'fratenum' : videonum, 'frateden' :  videodenom }
-               self.videoinformation.set_markup(''.join(('<small>', 'Video width&#47;height: ', str(videowidth),
-                                            "x", str(videoheight), '</small>')))
-               self.videocodec.set_markup(''.join(('<small>', 'Video codec: ',
-                                       str(gst.pbutils.get_codec_description(self.inputvideocaps)),
-                                      '</small>')))
+
            self.discover_done=True
            if self.havevideo==False:
                self.videoinformation.set_markup(''.join(('<small>', _("No Video"), '</small>')))
@@ -592,6 +592,18 @@ class TransmageddonUI:
                        self._start_transcoding()
            if self.container != False:
                self.check_for_passthrough(self.container)
+       # set markup
+
+       self.audioinformation.set_markup(''.join(('<small>', \
+                       'Audio channels: ', str(audiochannels[0]), '</small>')))
+       self.audiocodec.set_markup(''.join(('<small>','Audio codec: ', \
+                       str(gst.pbutils.get_codec_description(inputaudiocaps[audiostreamcounter])), \
+                       '</small>')))
+       self.videoinformation.set_markup(''.join(('<small>', 'Video width&#47;height: ', str(videowidth),
+                                            "x", str(videoheight), '</small>')))
+       self.videocodec.set_markup(''.join(('<small>', 'Video codec: ',
+                                       str(gst.pbutils.get_codec_description(self.inputvideocaps)),
+                                      '</small>')))
 
    def discover(self, path):
        self.discovered.discover_uri_async("file://"+path)
@@ -605,10 +617,8 @@ class TransmageddonUI:
        videointersect = ("EMPTY")
        audiointersect = ("EMPTY")
        if (containerchoice != False or self.usingpreset==False):
-           # print "container is " + str(containerchoice)
            container = codecfinder.containermap[containerchoice]
            containerelement = codecfinder.get_muxer_element(container)
-           # print "container element is " + str(containerelement)
            if containerelement == False:
                self.containertoggle = True
                self.check_for_elements()
@@ -619,7 +629,15 @@ class TransmageddonUI:
                        sourcecaps = x.get_caps()
                        if self.havevideo == True:
                           if videointersect == ("EMPTY"):
-                              videointersect = sourcecaps.intersect(self.videodata['videotype'])
+                              # clean accepted caps to 'pure' value without parsing requirements
+                              # might be redudant and caused by encodebin bug
+                              textdata=gst.Caps.to_string(self.videodata['videotype'])
+                              sep= ','
+                              minitext = textdata.split(sep, 1)[0]
+                              cleaned_videodata=gst.Caps(minitext)
+
+                              videointersect = sourcecaps.intersect(cleaned_videodata)
+
                               if videointersect != ("EMPTY"):
                                   self.vsourcecaps = videointersect
                        if self.haveaudio == True:
@@ -665,8 +683,11 @@ class TransmageddonUI:
            ratednom = self.videodata['frateden']
            if self.videopasstoggle == False:
                videocodec = self.VideoCodec
-           else:
-               videocodec = gst.Caps.to_string(self.vsourcecaps)
+           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
            outputdirectory=self.videodirectory
        else:
            outputdirectory=self.audiodirectory
@@ -684,6 +705,7 @@ class TransmageddonUI:
        else:
            audiocodec=False
            achannels=False
+
        self._transcoder = transcoder_engine.Transcoder(filechoice, self.filename, outputdirectory, self.container, 
                                                        audiocodec, videocodec, self.devicename, 
                                                        vheight, vwidth, ratenum, ratednom, achannels, 
@@ -930,7 +952,7 @@ class TransmageddonUI:
        self.CodecBox.set_sensitive(True)
        self.ProgressBar.set_fraction(0.0)
        self.ProgressBar.set_text(_("Transcoding Progress"))
-       print "container menu number is " + str(self.builder.get_object("containerchoice").get_active())
+       # print "container menu number is " + str(self.builder.get_object("containerchoice").get_active())
        if self.builder.get_object("containerchoice").get_active() == self.nocontainernumber:
                self.container = False
        else:



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