[transmageddon] fix transcoding with profiles



commit 2607f6d0b7969c68263fd627d08119faf44f56d2
Author: Christian Fredrik Kalager Schaller <christian schaller collabora co uk>
Date:   Sat May 28 11:59:35 2011 +0100

    fix transcoding with profiles

 src/transcoder_engine.py |   64 ++++++++++++++++++++++++++++------------------
 1 files changed, 39 insertions(+), 25 deletions(-)
---
diff --git a/src/transcoder_engine.py b/src/transcoder_engine.py
index 6782677..8384210 100644
--- a/src/transcoder_engine.py
+++ b/src/transcoder_engine.py
@@ -68,12 +68,13 @@ class Transcoder(gobject.GObject):
        self.inputvideocaps = INPUTVIDEOCAPS
        self.doaudio= False
        self.preset = PRESET
+       print "self.preset is " + str(self.preset)
        self.oheight = OHEIGHT
        self.owidth = OWIDTH
        self.fratenum = FRATENUM
        self.frateden = FRATEDEN
        self.achannels = ACHANNELS
-       # print "transcoder_engine achannels is " + str(self.achannels)
+       print "transcoder_engine achannels is " + str(self.achannels)
        self.blackborderflag = False
        self.multipass = MULTIPASS
        self.passcounter = PASSCOUNTER
@@ -98,14 +99,21 @@ class Transcoder(gobject.GObject):
        # gather preset data if relevant
        if self.preset != "nopreset":
            height, width, num, denom, pixelaspectratio = self.provide_presets()
+           print "height is " + str(height)
+           print "width is " + str(width)
+           print "num is " + str(num)
+           print "denom is " + str(denom)
+           print "pixelaspect is " + str(pixelaspectratio)
            for acap in self.audiocaps:
                acap["channels"] = self.channels
            for vcap in self.videocaps:
-               vcap["height"] = height
-               vcap["width"] = width
+               vcap["height"] = int(height)
+               vcap["width"] = int(width)
                vcap["framerate"] = gst.Fraction(num, denom)
                if pixelaspectratio != gst.Fraction(0, 0):
                    vcap["pixel-aspect-ratio"] = pixelaspectratio
+           print "video caps with preset are " + str(self.videocaps)
+           print "audio caps with preset are " + str(self.audiocaps)
 
 
        # Create transcoding pipeline
@@ -117,26 +125,31 @@ 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
+       print "self.container is " + str(self.container)
        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")
            elif self.audiocaps.intersect(gst.Caps("audio/x-flac")):
                self.audiocaps=gst.Caps("audio/x-flac")
        else:
+           print "self.containercaps are " + str(self.containercaps)
            self.encodebinprofile = gst.pbutils.EncodingContainerProfile ("containerformat", None , self.containercaps, None)
        if self.container==False:
            self.encodebinprofile = gst.pbutils.EncodingAudioProfile (self.audiocaps, None, gst.caps_new_any(), 0)
        else:
+           print "audiocaps used to create encodebin is " + str(self.audiocaps)
            self.audioprofile = gst.pbutils.EncodingAudioProfile (self.audiocaps, None, gst.caps_new_any(), 0)
            self.encodebinprofile.add_profile(self.audioprofile)
        if self.videocaps != "novid":
            if (self.videocaps != False):
-               self.videoprofile = gst.pbutils.EncodingVideoProfile (self.videocaps, None, gst.caps_new_any(), 0)
+               print "videcaps used to create encodebin is " + str(gst.Caps(self.videocaps))
+               self.videoprofile = gst.pbutils.EncodingVideoProfile (gst.Caps(self.videocaps), None, 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)
        self.encodebin.set_property("avoid-reencoding", True)
        self.pipeline.add(self.encodebin)
+       self.encodebin.set_state(gst.STATE_PAUSED)
 
        if self.videopasstoggle==False:
            self.videoflipper = gst.element_factory_make("videoflip")
@@ -155,26 +168,26 @@ class Transcoder(gobject.GObject):
            self.colorspaceconversion.set_state(gst.STATE_PAUSED)
            self.videoflipper.set_state(gst.STATE_PAUSED)
 
-       self.remuxcaps = gst.Caps()
-       if self.audiopasstoggle:
-          self.remuxcaps.append(self.audiocaps)
-       if self.videopasstoggle:
-          self.remuxcaps.append(self.videocaps)
-       if self.audiopasstoggle and not self.videopasstoggle:
-          self.remuxcaps.append_structure(gst.Structure("video/x-raw-rgb"))
-          self.remuxcaps.append_structure(gst.Structure("video/x-raw-yuv"))
-       if self.videopasstoggle and not self.audiopasstoggle:
-          self.remuxcaps.append_structure(gst.Structure("audio/x-raw-float"))
-          self.remuxcaps.append_structure(gst.Structure("audio/x-raw-int"))
-       if self.videocaps=="novid":
-          if self.inputvideocaps != None:
-              self.remuxcaps.append(self.inputvideocaps)
-              self.remuxcaps.append_structure(gst.Structure("audio/x-raw-float"))
-              self.remuxcaps.append_structure(gst.Structure("audio/x-raw-int"))
-
-
-       if (self.audiopasstoggle) or (self.videopasstoggle) or (self.videocaps=="novid"):
-           self.uridecoder.set_property("caps", self.remuxcaps)
+       #self.remuxcaps = gst.Caps()
+       #if self.audiopasstoggle:
+       #   self.remuxcaps.append(self.audiocaps)
+       #if self.videopasstoggle:
+       #   self.remuxcaps.append(self.videocaps)
+       #if self.audiopasstoggle and not self.videopasstoggle:
+       #   self.remuxcaps.append_structure(gst.Structure("video/x-raw-rgb"))
+       #   self.remuxcaps.append_structure(gst.Structure("video/x-raw-yuv"))
+       #if self.videopasstoggle and not self.audiopasstoggle:
+       #   self.remuxcaps.append_structure(gst.Structure("audio/x-raw-float"))
+       #   self.remuxcaps.append_structure(gst.Structure("audio/x-raw-int"))
+       #if self.videocaps=="novid":
+       #   if self.inputvideocaps != None:
+       #       self.remuxcaps.append(self.inputvideocaps)
+       #       self.remuxcaps.append_structure(gst.Structure("audio/x-raw-float"))
+       #       self.remuxcaps.append_structure(gst.Structure("audio/x-raw-int"))
+
+
+       #if (self.audiopasstoggle) or (self.videopasstoggle) or (self.videocaps=="novid"):
+       #    self.uridecoder.set_property("caps", self.remuxcaps)
  
        self.pipeline.add(self.uridecoder)
 
@@ -186,7 +199,7 @@ class Transcoder(gobject.GObject):
        self.encodebin.link(self.transcodefileoutput)
 
        self.uridecoder.set_state(gst.STATE_PAUSED)
-       self.encodebin.set_state(gst.STATE_PAUSED)
+
        # print "setting uridcodebin to paused"
        self.BusMessages = self.BusWatcher()
 
@@ -356,6 +369,7 @@ class Transcoder(gobject.GObject):
                #elif a.startswith("video/"):
                #    src_pad.link(self.fakesink.get_static_pad("sink"))
            else:
+               print "encodebin is " + str(self.encodebin)
                sinkpad = self.encodebin.emit("request-pad", src_pad.get_caps())
                c = sinkpad.get_caps().to_string()
                if c.startswith("audio/"):



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