def render_single(self): if not self.input_file is None and not (self.output_file is None): print self.input_file, self.output_file if self.verbose: print "Converting to NDVI..." try: ndvi(self.input_file,self.output_file,**self.ndvi_kwargs) except KeyboardInterrupt: pass
def render_single(self): if not self.input_file is None and not (self.output_file is None): print self.input_file, self.output_file if self.verbose: print "Converting to NDVI..." try: ndvi(self.input_file, self.output_file, **self.ndvi_kwargs) except KeyboardInterrupt: pass
def render_avconv(self, video_codec = 'libx264', frame_rate = 24.0, vsync = 'cfr', ): #extract keyword arguments # Frame extraction #if input file is specified reduce it to frames, otherwise skip if not self.input_file is None: cmd = ["avconv"] cmd.append("-i %s" % self.input_file) cmd.append("-y") #overwrite files without prompting frame_file_format = os.sep.join((self.temp_dir,r"frame%09d.png")) #note that %d formatter is deliberately escaped for avconv's use cmd.append(frame_file_format) #output cmd = " ".join(cmd) if self.verbose: print "Extracting frames..." print "\tRunning command: %s" % cmd try: run_cmd(cmd) except KeyboardInterrupt: pass # NDVI conversion if self.verbose: print "Converting to all frames NDVI..." frame_file_pattern = os.sep.join((self.temp_dir,r"frame[0-9]*.png")) frame_filenames = sorted(glob.glob(frame_file_pattern)) try: for frame_fn in frame_filenames: ndvi_fn = frame_fn.replace("frame","ndvi") if self.verbose: print "generating ndvi plot: %s (press ctr-c to stop early)" % ndvi_fn ndvi(frame_fn, imageOutPath = ndvi_fn, **self.ndvi_kwargs ) except KeyboardInterrupt: pass # Movie Encoding ndvi_file_format = os.sep.join((self.temp_dir,r"ndvi%09d.png")) cmd = ["avconv"] cmd.append("-y") #overwrite files without prompting cmd.append("-i %s" % ndvi_file_format) cmd.append("-c:v %s" % video_codec) cmd.append("-r %f" % frame_rate) cmd.append("-vsync %s" % vsync) cmd.append(self.output_file) #output cmd = " ".join(cmd) if self.verbose: print "Rendering movie..." print "\tRunning command: %s" % cmd try: run_cmd(cmd) except KeyboardInterrupt: pass
def render_avconv( self, video_codec='libx264', frame_rate=24.0, vsync='cfr', ): #extract keyword arguments # Frame extraction #if input file is specified reduce it to frames, otherwise skip if not self.input_file is None: cmd = ["avconv"] cmd.append("-i %s" % self.input_file) cmd.append("-y") #overwrite files without prompting frame_file_format = os.sep.join( (self.temp_dir, r"frame%09d.png") ) #note that %d formatter is deliberately escaped for avconv's use cmd.append(frame_file_format) #output cmd = " ".join(cmd) if self.verbose: print "Extracting frames..." print "\tRunning command: %s" % cmd try: run_cmd(cmd) except KeyboardInterrupt: pass # NDVI conversion if self.verbose: print "Converting to all frames NDVI..." frame_file_pattern = os.sep.join((self.temp_dir, r"frame[0-9]*.png")) frame_filenames = sorted(glob.glob(frame_file_pattern)) try: for frame_fn in frame_filenames: ndvi_fn = frame_fn.replace("frame", "ndvi") if self.verbose: print "generating ndvi plot: %s (press ctr-c to stop early)" % ndvi_fn ndvi(frame_fn, imageOutPath=ndvi_fn, **self.ndvi_kwargs) except KeyboardInterrupt: pass # Movie Encoding ndvi_file_format = os.sep.join((self.temp_dir, r"ndvi%09d.png")) cmd = ["avconv"] cmd.append("-y") #overwrite files without prompting cmd.append("-i %s" % ndvi_file_format) cmd.append("-c:v %s" % video_codec) cmd.append("-r %f" % frame_rate) cmd.append("-vsync %s" % vsync) cmd.append(self.output_file) #output cmd = " ".join(cmd) if self.verbose: print "Rendering movie..." print "\tRunning command: %s" % cmd try: run_cmd(cmd) except KeyboardInterrupt: pass