Exemplo n.º 1
0
    def render(self, filename, outputPath, startFrame, endFrame, format, updateCompletion, extraParams={}):
        comp = 0.0
        updateCompletion(comp)

        output = os.path.join(outputPath,"file")
        if not os.path.exists(outputPath):
            os.mkdir(outputPath)

        if self.version > StrictVersion('0.6.0'):
            commandline=[self.conf['binary'], filename, "-o", output, "--width", extraParams['width'], "--height", extraParams['height'], "--start", startFrame, "--end", endFrame]
            if is_true_string(extraParams['transparency']):
                commandline.append("--transparency")
            if extraParams['camera']:
                commandline.extend(["--camera", extraParams['camera']])
        elif self.version == StrictVersion('0.6.0'):
            commandline=[self.conf['binary'], filename, "--export-sequence", output, "--width", extraParams['width'], "--height", extraParams['height']]
            if is_true_string(extraParams['transparency']):
                commandline.append("--transparency")
        else:
            commandline=[self.conf['binary'], filename, "--export-sequence", output]

        print(commandline)
        subprocess.check_call(commandline)

        updateCompletion(1.0)
Exemplo n.º 2
0
    def render(self,
               filename,
               outputPath,
               startFrame,
               endFrame,
               format,
               updateCompletion,
               extraParams={}):
        comp = 0.0
        updateCompletion(comp)

        output = os.path.join(outputPath, "file")
        if not os.path.exists(outputPath):
            os.mkdir(outputPath)

        if self.version > StrictVersion('0.6.0'):
            commandline = [
                self.conf['binary'], filename, "-o", output, "--width",
                extraParams['width'], "--height", extraParams['height'],
                "--start",
                str(startFrame), "--end",
                str(endFrame)
            ]
            if is_true_string(extraParams['transparency']):
                commandline.append("--transparency")
            if ('camera' in extraParams) and (extraParams['camera']):
                commandline.extend(["--camera", extraParams['camera']])
        elif self.version == StrictVersion('0.6.0'):
            commandline = [
                self.conf['binary'], filename, "--export-sequence", output,
                "--width", extraParams['width'], "--height",
                extraParams['height']
            ]
            if is_true_string(extraParams['transparency']):
                commandline.append("--transparency")
        else:
            commandline = [
                self.conf['binary'], filename, "--export-sequence", output
            ]

        print(commandline)
        subprocess.check_call(commandline)

        updateCompletion(1.0)
Exemplo n.º 3
0
    def render(self, filename, outputPath, startFrame, endFrame, format, updateCompletion, extraParams={}):

        comp = 0.0
        updateCompletion(comp)

        totalFrames = endFrame - startFrame + 1
        #/path/to/file.sifz.png: Line 10 of 100 -- 1m 14s
        frameNumberPattern = re.compile(": Line (\d+) of \d+ -- ")

        if format in RenderChanModule.imageExtensions and extraParams["single"]=="None":
            try:
                os.makedirs(outputPath)
            except OSError as exc: # Python >2.5
                if exc.errno == errno.EEXIST and os.path.isdir(outputPath):
                    pass
                else: raise
            outputPath=os.path.join(outputPath, "file."+format)


        commandline=[self.conf['binary'], "-o",outputPath, "-w", str(int(extraParams["width"])), "-h", str(int(extraParams["height"]))]
        commandline.append("--sequence-separator")
        commandline.append(".")

        if format == "avi":
            commandline.append("-t")
            commandline.append("ffmpeg")
            commandline.append("--video-codec")
            commandline.append("libx264-lossless")
            commandline.append("--video-bitrate")
            commandline.append("2000")
        else:
            commandline.append("-t")
            commandline.append("png")

        if extraParams["single"]=="None":
            commandline.append("--start-time")
            commandline.append(str(startFrame)+"f")
            commandline.append("--end-time")
            commandline.append(str(endFrame)+"f")
        else:
            commandline.append("--time")
            commandline.append(extraParams["single"]+"f")

        if is_true_string(extraParams["extract_alpha"]):
            commandline.append("-x")

        commandline.append(filename)

        #print(" ".join(commandline))
        out = subprocess.Popen(commandline, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0)
        rc = None
        while True:
            #line = out.stdout.readline().decode("utf-8")
            line = out.stdout.readline().decode(locale.getpreferredencoding(), errors='replace')
            #line = out.stdout.readline()
            if not line:
                if rc is not None:
                    break
            #print(line, end=' ')
            sys.stdout.buffer.write(line.encode(locale.getpreferredencoding(), errors='replace'))
            sys.stdout.flush()
            fn = frameNumberPattern.search(line)
            if fn:
                currentFrame = float(fn.group(1).strip())
                fc = float(currentFrame / 100) / float(totalFrames)
                updateCompletion(comp + fc)
            rc = out.poll()

        print('====================================================')
        print('  Synfig command returns with code %d' % rc)
        print('====================================================')
        if rc != 0:
            if os.name == 'nt' and rc == -1073741819:
                pass
            else:
                print('  Synfig command failed...')
                raise Exception('  Synfig command failed...')
        updateCompletion(1)
Exemplo n.º 4
0
    def getParams(self, force_proxy):
        params={}

        # Basic project values
        for key in self.project.defaults.keys():
            if self.project:
                if self.module.getName()+"."+key in self.project.config.keys():
                    params[key]=self.project.getConfig(self.module.getName()+"."+key)
                else:
                    params[key]=self.project.getConfig(key)
            if key in self.config:
                if self.config[key].startswith("*"):
                    params[key]=float(self.config[key][1:])*float(params[key])
                else:
                    params[key]=self.config[key]

        # Module-specific configuration
        for key in self.module.extraParams.keys():
            params[key]=self.module.extraParams[key]
            if key in self.project.config.keys():
                params[key]=self.project.config[key]
            if self.module.getName()+"."+key in self.project.config.keys():
                params[key]=self.project.config[self.module.getName()+"."+key]
            if key in self.config.keys():
                if self.config[key].startswith("*"):
                    params[key]=float(self.config[key][1:])*float(params[key])
                else:
                    params[key]=self.config[key]

        if 'use_own_dimensions' in params.keys() and is_true_string(params['use_own_dimensions']):
            params['width']=self.width
            params['height']=self.height

        # Special routines related with proxies
        if 'use_own_dimensions' in params.keys() and 'proxy_scale' in params.keys():
            if is_true_string(params['use_own_dimensions']) and 'width' in params.keys() and 'height' in params.keys():
                if params['proxy_scale']!='1.0':
                    try:
                        proxy_scale = float(params['proxy_scale'])
                    except:
                        print("WARNING: Wrong value for 'proxy scale' (%s)." % self.getPath())
                        proxy_scale = 1.0
                    width=int(params['width'])
                    height=int(params['height'])
                    if not force_proxy and (((width*proxy_scale) % 1) != 0 or ((height*proxy_scale) % 1) != 0):
                        print("WARNING: Can't apply 'proxy scale' for file (%s):" % self.getPath())
                        print("         Dimensions %sx%s give non-integer values when multiplied by factor of %s." % (width, height, proxy_scale))
                    else:
                        params['width'] = str(width*proxy_scale)
                        params['height'] = str(height*proxy_scale)

        # File-specific configuration
        #params["filename"]=self.getPath()
        #params["output"]=self.getRenderPath()
        #params["profile_output"]=self.getProfileRenderPath()
        #params["module"]=self.module.getName()
        #params["packetSize"]=self.getPacketSize()
        #params["start"]=self.getStartFrame()
        #params["end"]=self.getEndFrame()
        params["dependencies"]=self.getDependencies()
        params["projectVersion"]=self.project.version
        #params["profileDir"]=self.project.getProfileDirName()
        #params["projects"] = []

        return params
Exemplo n.º 5
0
    def render(self, filename, outputPath, startFrame, endFrame, format, updateCompletion, extraParams={}):

        comp = 0.0
        updateCompletion(comp)

        totalFrames = endFrame - startFrame + 1
        #/path/to/file.sifz.png: Line 10 of 100 -- 1m 14s
        frameNumberPattern = re.compile(": Line (\d+) of \d+ -- ")

        if format in RenderChanModule.imageExtensions and extraParams["single"]=="None":
            try:
                os.makedirs(outputPath)
            except OSError as exc: # Python >2.5
                if exc.errno == errno.EEXIST and os.path.isdir(outputPath):
                    pass
                else: raise
            outputPath=os.path.join(outputPath, "file."+format)


        commandline=[self.conf['binary'], "-o",outputPath, "-w", str(int(extraParams["width"])), "-h", str(int(extraParams["height"]))]
        commandline.append("--sequence-separator")
        commandline.append(".")

        if format == "avi":
            commandline.append("-t")
            commandline.append("ffmpeg")
            commandline.append("--video-codec")
            commandline.append("libx264-lossless")
            commandline.append("--video-bitrate")
            commandline.append("2000")
        else:
            commandline.append("-t")
            commandline.append("png")

        if extraParams["single"]=="None":
            commandline.append("--start-time")
            commandline.append(str(startFrame)+"f")
            commandline.append("--end-time")
            commandline.append(str(endFrame)+"f")
        else:
            commandline.append("--time")
            commandline.append(extraParams["single"]+"f")

        if is_true_string(extraParams["extract_alpha"]):
            commandline.append("-x")

        commandline.append(filename)

        #print(" ".join(commandline))
        out = subprocess.Popen(commandline, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, bufsize=0)
        rc = None
        #currentFrame = None
        while rc is None:
            line = out.stdout.readline().decode("utf-8")
            if not line:
                break
            print(line, end=' ')
            sys.stdout.flush()
            fn = frameNumberPattern.search(line)
            if fn:
                currentFrame = float(fn.group(1).strip())
                fc = float(currentFrame / 100) / float(totalFrames)
                updateCompletion(comp + fc)
            rc = out.poll()

        out.communicate()
        rc = out.poll()
        print('====================================================')
        print('  Synfig command returns with code %d' % rc)
        print('====================================================')
        if rc != 0:
            if os.name == 'nt' and rc == -1073741819:
                pass
            else:
                print('  Synfig command failed...')
                raise Exception('  Synfig command failed...')
        updateCompletion(1)
Exemplo n.º 6
0
    def getParams(self, force_proxy):
        params = {}

        # Basic project values
        for key in self.project.defaults.keys():
            if self.project:
                if self.module.getName(
                ) + "." + key in self.project.config.keys():
                    params[key] = self.project.getConfig(
                        self.module.getName() + "." + key)
                else:
                    params[key] = self.project.getConfig(key)
            if key in self.config:
                if self.config[key].startswith("*"):
                    params[key] = float(self.config[key][1:]) * float(
                        params[key])
                else:
                    params[key] = self.config[key]

        # Module-specific configuration
        for key in self.module.extraParams.keys():
            params[key] = self.module.extraParams[key]
            if key in self.project.config.keys():
                params[key] = self.project.config[key]
            if self.module.getName() + "." + key in self.project.config.keys():
                params[key] = self.project.config[self.module.getName() + "." +
                                                  key]
            if key in self.config.keys():
                if self.config[key].startswith("*"):
                    params[key] = float(self.config[key][1:]) * float(
                        params[key])
                else:
                    params[key] = self.config[key]

        if 'use_own_dimensions' in params.keys() and is_true_string(
                params['use_own_dimensions']):
            params['width'] = self.width
            params['height'] = self.height

        # Special routines related with proxies
        if 'use_own_dimensions' in params.keys(
        ) and 'proxy_scale' in params.keys():
            if is_true_string(
                    params['use_own_dimensions']) and 'width' in params.keys(
                    ) and 'height' in params.keys():
                if params['proxy_scale'] != '1.0':
                    try:
                        proxy_scale = float(params['proxy_scale'])
                    except:
                        print("WARNING: Wrong value for 'proxy scale' (%s)." %
                              self.getPath())
                        proxy_scale = 1.0
                    width = int(params['width'])
                    height = int(params['height'])
                    if not force_proxy and (((width * proxy_scale) % 1) != 0 or
                                            ((height * proxy_scale) % 1) != 0):
                        print(
                            "WARNING: Can't apply 'proxy scale' for file (%s):"
                            % self.getPath())
                        print(
                            "         Dimensions %sx%s give non-integer values when multiplied by factor of %s."
                            % (width, height, proxy_scale))
                    else:
                        params['width'] = str(width * proxy_scale)
                        params['height'] = str(height * proxy_scale)

        # File-specific configuration
        #params["filename"]=self.getPath()
        #params["output"]=self.getRenderPath()
        #params["profile_output"]=self.getProfileRenderPath()
        #params["module"]=self.module.getName()
        #params["packetSize"]=self.getPacketSize()
        #params["start"]=self.getStartFrame()
        #params["end"]=self.getEndFrame()
        params["dependencies"] = self.getDependencies()
        params["projectVersion"] = self.project.version
        #params["profileDir"]=self.project.getProfileDirName()
        #params["projects"] = []

        return params