コード例 #1
0
ファイル: thumbs.py プロジェクト: styk-tv/Cloud-Media-Encoder
 def __init__(self,reporter, workflow,task):
     super(ThumbsExecutor, self).__init__(reporter, workflow, task)
     elist=EncodersList()
     self.eparams=elist.getByUuid(task.attributes["encoder"]) 
     if self.eparams==None: raise Exception("No encoder with guid "+task.attributes["encoder"])
     if self.eparams.type<>"ffmpeg_0612": raise Exception("Unknown encoder type "+self.eparams.type)
     slist=LocalStoreList()
     self.frames=1
     self.destAsset=task.attributes["srcAssetItem"]
     if task.attributes.has_key("destAssetItem"): self.destAsset=task.attributes["destAssetItem"]
     
     self.srcfile=slist.getByUuid(task.attributes["srcStore"]).findAssetFile(task.attributes["srcAssetItem"], task.attributes["srcAssetItemType"])
     self.targetdir=slist.getByUuid(task.attributes["destStore"]).findAsset(self.destAsset)
     if not os.path.exists(self.targetdir): os.makedirs(self.targetdir)
コード例 #2
0
    def __init__(self,reporter, workflow,task):
        super(EncoderExecutor, self).__init__(reporter, workflow, task)
        elist=EncodersList()
        self.eparams=elist.getByUuid(task.attributes["encoder"]) 
        if self.eparams==None: raise Exception("No encoder with guid "+task.attributes["encoder"])
        if self.eparams.type=="ffmpeg_0612": self.encoder=FFmpegEncoder(self)
        else:  raise Exception("Unknown encoder type "+self.eparams.type)
        slist=LocalStoreList()
        self.frames=1
        self.overwrite=False
        if task.attributes.has_key("overwrite"): self.overwrite=(task.attributes["overwrite"].lower()=="true")
        dstAsset=task.attributes["srcAssetItem"]
        if task.attributes.has_key("destAssetItem"): dstAsset=task.attributes["destAssetItem"]

        srcstore=slist.getByUuid(task.attributes["srcStore"])
        (ext, self.srcFps)=srcstore.decodeAssetType(task.attributes["srcAssetItemType"])
        self.srcfile=getFFPath(srcstore, task.attributes["srcAssetItem"], task.attributes["srcAssetItemType"])
        targetdir=slist.getByUuid(task.attributes["destStore"]).findAsset(dstAsset)
        if not os.path.exists(targetdir): os.makedirs(targetdir)
        self.outfile=slist.getByUuid(task.attributes["destStore"]).findAssetFile(dstAsset, self.eparams.outputtype)
コード例 #3
0
    def __init__(self,reporter, workflow,task):
        super(ImgRotateExecutor, self).__init__(reporter, workflow, task)
        elist=EncodersList()
        self.eparams=elist.getByUuid(task.attributes["encoder"]) 
        if self.eparams==None: raise Exception("No encoder with guid "+task.attributes["encoder"])
        slist=LocalStoreList()
        dstAsset=task.attributes["srcAssetItem"]
        if task.attributes.has_key("destAssetItem"): dstAsset=task.attributes["destAssetItem"]

        self.srcfile=slist.getByUuid(task.attributes["srcStore"]).findAssetFile(task.attributes["srcAssetItem"], task.attributes["srcAssetItemType"])
        targetdir=slist.getByUuid(task.attributes["destStore"]).findAsset(dstAsset)
        if not os.path.exists(targetdir): os.makedirs(targetdir)
        self.outfile=slist.getByUuid(task.attributes["destStore"]).findAssetFile(dstAsset, self.eparams.outputtype)
        type=task.attributes["direction"]
        if type=="CCW90" or type=="CW270": self.type=Image.ROTATE_90
        elif type=="CCW180" or type=="CW180": self.type=Image.ROTATE_180
        elif type=="CCW270" or type=="CW90": self.type=Image.ROTATE_270
        elif type=="VFLIP": self.type=Image.FLIP_TOP_BOTTOM
        elif type=="HFLIP": self.type=Image.FLIP_LEFT_RIGHT
        else: raise Exception("Wrong direction")
コード例 #4
0
    def __init__(self,reporter, workflow,task):
        super(ImgResizeExecutor, self).__init__(reporter, workflow, task)
        elist=EncodersList()
        self.eparams=elist.getByUuid(task.attributes["encoder"]) 
        if self.eparams==None: raise Exception("No encoder with guid "+task.attributes["encoder"])
        if self.eparams.type<>"PIL":  raise Exception("Unknown encoder type "+self.eparams.type)
        slist=LocalStoreList()
        self.frames=1
        dstAsset=task.attributes["srcAssetItem"]
        if task.attributes.has_key("destAssetItem"): dstAsset=task.attributes["destAssetItem"]

        self.srcfile=slist.getByUuid(task.attributes["srcStore"]).findAssetFile(task.attributes["srcAssetItem"], task.attributes["srcAssetItemType"])
        targetdir=slist.getByUuid(task.attributes["destStore"]).findAsset(dstAsset)
        if not os.path.exists(targetdir): os.makedirs(targetdir)
        self.outfile=slist.getByUuid(task.attributes["destStore"]).findAssetFile(dstAsset, self.eparams.outputtype)
        self.watermarkFile=None
        
        if self.eparams.watermarkFile<>"":
            self.watermarkFile=Config.CONFIGDIR+"/"+self.eparams.watermarkFile
        elif self.eparams.watermarkAsset<>"":
            slist=LocalStoreList()
            store=slist.getByUuid(self.eparams.watermarkStore)
            self.watermarkFile=store.findAssetFile(self.eparams.watermarkAsset, self.eparams.watermarkAssetType)
コード例 #5
0
def main():
    try:
        if len(sys.argv)<2: raise Exception("Usage: encoders.py <types>|<list>|<create>|<remove>")
        action=sys.argv[1]
        stores=EncodersList()
        if action=="list": stores.write(sys.stdout)
        elif action=="types": stores.writeTypes(sys.stdout)
        elif action=="create": 
            ret=stores.create(sys.stdin)
            return xmlmsg("result", ret)
        elif action=="remove":
            if len(sys.argv)<3: raise Exception("Usage: encoders.py remove <encoder>")
            ret=stores.remove(sys.argv[2],)
            return xmlmsg("result", ret)
        else: raise Exception("Usage: encoders.py <types>|<list>|<create>|<remove>")
    except Exception, e:
        return xmlmsg("error", str(e))