[transmageddon] Code fixes and cleanups after change to the new audiodata and videodata lists



commit 43b5e168a90d87759900c85d787b9ca82a1dc8bf
Author: Christian Fredrik Kalager Schaller <uraeus linuxrisin org>
Date:   Fri Jan 4 15:09:53 2013 +0100

    Code fixes and cleanups after change to the new audiodata and videodata lists

 src/transcoder_engine.py |   56 ++++++++++++++-------------------------------
 src/transmageddon.py     |   24 +++++++++++++------
 2 files changed, 34 insertions(+), 46 deletions(-)
---
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index b25ff33..5d227fb 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -59,19 +59,9 @@ class Transcoder(GObject.GObject):
        # Choose plugin based on Codec Name
        # or switch to remuxing mode if any of the values are set to 'pastr'
        self.stoptoggle=False
-       #self.videocaps = self.videodata[0]['outputvideocaps']  # "novid" means we have a video file input, but do not want it
-       #self.audiopasstoggle = AUDIOPASSTOGGLE
-       #self.interlaced = INTERLACED
-       #self.videopasstoggle = VIDEOPASSTOGGLE
-       #self.inputvideocaps = INPUTVIDEOCAPS
+
        self.doaudio= False
        self.preset = PRESET
-       #self.oheight = OHEIGHT
-       #self.owidth = OWIDTH
-       #self.fratenum = FRATENUM
-       #self.frateden = FRATEDEN
-       #self.achannels = self.audiodata[0]['audiochannels']
-       #self.astreamid = self.audiodata[0]['streamid']
        self.blackborderflag = False
        self.multipass = MULTIPASS
        self.passcounter = PASSCOUNTER
@@ -81,16 +71,14 @@ class Transcoder(GObject.GObject):
        self.missingplugin= False
        self.probestreamid = False
        self.sinkpad = False
-       print(self.sinkpad)
-
-          
 
        # switching width and height around for rotationchoices where it makes sense
        if self.rotationvalue == 1 or self.rotationvalue == 3:
-           nwidth = self.oheight
-           nheight = self.owidth
-           self.oheight = nheight
-           self.owidth = nwidth 
+           print(self.videodata[0])
+           nwidth = self.videodata[0]['videoheight']
+           nheight = self.videodata[0]['videowidth']
+           self.videodata[0]['videoheight'] = nheight
+           self.videodata[0]['videowidth'] = nwidth 
 
        # if needed create a variable to store the filename of the multipass \
        # statistics file
@@ -154,17 +142,16 @@ class Transcoder(GObject.GObject):
 
        # We do not need to do anything special for passthrough for audio, since we are not
        # including any extra elements between uridecodebin and encodebin
-       if self.audiodata[0]['outputaudiocaps'] != False:
-           print("We should add only one audio pad to encodebin")
-           if self.container==False:
-               print("yo")
-               print(self.audiodata[0]['outputaudiocaps'])
-               self.encodebinprofile = GstPbutils.EncodingAudioProfile.new (self.audiodata[0]['outputaudiocaps'], audiopreset, Gst.Caps.new_any(), 0)
-           else:
-               print("yay")
-               audiopreset=None
-               self.audioprofile = GstPbutils.EncodingAudioProfile.new(self.audiodata[0]['outputaudiocaps'], audiopreset, Gst.Caps.new_any(), 0)
-               self.encodebinprofile.add_profile(self.audioprofile)
+       x=0
+       while x < len(self.audiodata): 
+           if self.audiodata[x]['outputaudiocaps'] != False:
+               if self.container==False:
+                   self.encodebinprofile = GstPbutils.EncodingAudioProfile.new (self.audiodata[x]['outputaudiocaps'], audiopreset, Gst.Caps.new_any(), 0)
+               else:
+                   audiopreset=None
+                   self.audioprofile = GstPbutils.EncodingAudioProfile.new(self.audiodata[x]['outputaudiocaps'], audiopreset, Gst.Caps.new_any(), 0)
+                   self.encodebinprofile.add_profile(self.audioprofile)
+           x=x+1 
        
        if self.passcounter != int(0):
            passvalue = "Pass "+ str(self.passcounter)
@@ -384,7 +371,7 @@ class Transcoder(GObject.GObject):
        origin = src_pad.query_caps(None)
        if (self.container==False):
            a =  origin.to_string()
-           if a.startswith("audio/"):
+           if a.startswith("audio/"): # FIXME : Currently an assumption here of one audio stream
                sinkpad = self.encodebin.get_static_pad("audio_0")
                src_pad.link(sinkpad)
        else:
@@ -400,28 +387,21 @@ class Transcoder(GObject.GObject):
                # currently.
                # Making sure that when we remove video from a file we don't
                # bother with the video pad.
-               print("we are where we want to be")
                c = origin.to_string()
                if not c.startswith("text/"):
                    if not (c.startswith("video/") and (self.videodata[0]['outputvideocaps'] == False)):
                        if self.passcounter == int(0):
                            self.sinkpad = self.encodebin.emit("request-pad", origin)
                if c.startswith("audio/"):
-                   print("ok, now we are getting somewhere")
                    if self.passcounter == int(0):
-                       # self.sinkpad = self.encodebin.emit("request-pad", origin)
                        src_pad.add_probe(Gst.PadProbeType.EVENT_DOWNSTREAM, self.padprobe, None)
-                       #if self.probestreamid==self.astreamid:
-                       #    print("got streamid from probe")
-                       #    src_pad.link(sinkpad)
                elif ((c.startswith("video/") or c.startswith("image/")) and (self.videodata[0]['outputvideocaps'] != False)):
-                   print("video detected")
                    if self.videodata[0]['dopassthrough']==False:
                        if (self.multipass != 0) and (self.passcounter != int(0)):
                            videoencoderpad = self.videoencoder.get_static_pad("sink")
                            src_pad.link(videoencoderpad)
                        else:
-                           # src_pad.add_probe(Gst.PadProbeType.EVENT_DOWNSTREAM, self.padprobe, None)
+                           # FIXME? if we want to do support multistream video we need a padprobe here too.
                            deinterlacerpad = self.deinterlacer.get_static_pad("sink")
                            src_pad.link(deinterlacerpad)
                            self.videoflipper.get_static_pad("src").link(self.sinkpad)   
diff --git a/src/transmageddon.py b/src/transmageddon.py
index 6fee20a..f29a7d9 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -587,7 +587,11 @@ class TransmageddonUI(Gtk.ApplicationWindow):
            self.start_time = False
            self.multipass = 0
            self.passcounter = 0
-           self.audiodata['FIXME']['passthrough']=False # should be for both do and can passthrough
+           x=0
+           while x <= self.audiostreamcounter:
+               self.audiodata[x]['dopassthrough']=False
+               self.audiodata[x]['canpassthrough']=False
+               x=x+1
            self.videodata[0]['dopassthrough']=False
            self.videodata[0]['canpassthrough']=False
            self.houseclean=False # due to not knowing which APIs to use I need
@@ -627,6 +631,8 @@ class TransmageddonUI(Gtk.ApplicationWindow):
                        self.audiostreamids.append(streamid)
                        self.haveaudio=True
                        self.audiodata.append(self.add_audiodata_row(i.get_channels(), i.get_sample_rate(), i.get_caps(), False, streamid, False, False, i.get_language()))
+                       if self.audiodata[self.audiostreamcounter]['language']== None:
+                           self.audiodata[self.audiostreamcounter]['language']=_("Unknown language")
                        if self.audiostreamcounter > 0:
                            combo = Gtk.ComboBoxText.new()
                            self.audiorows.append(combo)
@@ -651,13 +657,8 @@ class TransmageddonUI(Gtk.ApplicationWindow):
                        self.presetchoice.set_sensitive(True)
                        self.videorows[0].set_sensitive(True)
                        self.rotationchoice.set_sensitive(True)
-
-                   if self.havevideo==False:
-                       self.videoinformation.set_markup(''.join(('<small>', _("No Video"), '</small>', "\n", '<small>', "", '</small>')))
-                       self.presetchoice.set_sensitive(False)
-                       self.videorows[0].set_sensitive(False)
-                       self.rotationchoice.set_sensitive(False)
                self.discover_done=True
+               self.transcodebutton.set_sensitive(True)
 
                if self.waiting_for_signal == True:
                    if self.containertoggle == True:
@@ -689,8 +690,15 @@ class TransmageddonUI(Gtk.ApplicationWindow):
                        self.audioinformation.set_markup(''.join(('<small>', _("No Audio"), '</small>',"\n", '<small>', "",'</small>')))
 
 
-           if self.videodata[0]['videowidth'] and self.videodata[0]['videoheight']:
+           if self.havevideo==True:
                self.videoinformation.set_markup(''.join(('<small>', 'Video width&#47;height: ', str(self.videodata[0]['videowidth']), "x", str(self.videodata[0]['videoheight']), '</small>',"\n", '<small>', 'Video codec: ',  str(GstPbutils.pb_utils_get_codec_description   (self.videodata[0]['inputvideocaps'])), '</small>' )))
+           else: # in case of media being audio-only
+               if not self.videodata: # need to create this for non-video files too
+                   self.videodata.append(self.add_videodata_row(None, None, None, False, None, None, None, False, False, None)) 
+               self.videoinformation.set_markup(''.join(('<small>', _("No Video"), '</small>', "\n", '<small>', "", '</small>')))
+               self.presetchoice.set_sensitive(False)
+               self.videorows[0].set_sensitive(False)
+               self.rotationchoice.set_sensitive(False)
        else:
           print("hoped for a great discovery; got an error")
           print(result)



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