Example #1
0
	def getCommandLine(self, vcodec, filename):
		"""
		return the command line for using ffmpeg to render the video
		"""
		target = ""
		pattern = self.getPattern()
		if self.preset != 0:
			(x, y), fps, br, target = self.presets[self.preset]
		
		cmdLine = []
		if not scripting.main_is_frozen():
			ffmpegs = {"linux": "bin/ffmpeg", "linux2": "bin/ffmpeg", "win32": "bin\\ffmpeg.exe", "darwin": "bin/ffmpeg.osx"}
		else:
			ffmpegs = {"linux": "bin/ffmpeg", "linux2": "bin/ffmpeg", "win32": "bin\\ffmpeg.exe", "darwin": "../Resources/Bin/ffmpeg.osx"}
		ffmpeg = "ffmpeg"
		for i in ffmpegs.keys():
			if i == sys.platform:
				ffmpeg = ffmpegs[i]
				break
			
			
		bindir = scripting.get_main_dir()
		ffmpeg = os.path.join(bindir, ffmpeg)
		cmdLine.append(ffmpeg)
		# scale the quality into the range understood by ffmpeg
		quality = 11 - self.quality
		quality = math.ceil(1 + (3.22222 * (quality - 1)))
		frameRate = self.fps
		width, height = self.getSize()

		if not target:
			cmdLine.append("-y")
			cmdLine.append("-qscale")
			cmdLine.append("%d"%quality)
			cmdLine.append("-r")
			cmdLine.append("%.2f"%frameRate)
			cmdLine.append("-s")
			cmdLine.append("%dx%d"%(width, height))
			cmdLine.append("-i")
			cmdLine.append('%s'%pattern)
			cmdLine.append('-vcodec')
			cmdLine.append('%s'%vcodec)
			cmdLine.append('%s'%filename)
			#commandLine = "\"%s\" -y -qscale %d -r %.2f -s %dx%d -i \"%s\" -vcodec %s \"%s\"" \
			#				% (ffmpeg, quality, frameRate, width, height, pattern, vcodec, file)
		else:
			#commandLine = "\"%s\" -y -qscale %d -s %dx%d -i \"%s\" -target %s \"%s\"" % (ffmpeg, quality, width, height, pattern, target, file)
			cmdLine.append("-y")
			cmdLine.append("-qscale")
			cmdLine.append("%d"%quality)
			cmdLine.append("-s")
			cmdLine.append("%dx%d"%(width, height))
			cmdLine.append("-i")
			cmdLine.append('%s'%pattern)
			cmdLine.append('-target')
			cmdLine.append('%s'%target)
			cmdLine.append('%s'%filename)
		Logging.info("Command line for ffmpeg="+str(cmdLine), kw = "animator")
		return cmdLine
Example #2
0
	todir = os.getcwd()
	
if platform.system()=="Windows":
	itkpkg = os.path.join(todir, "ITK-pkg")
	if os.path.exists(itkpkg):
		itklibdir = os.path.join(itkpkg, "lib")
		itklibdir = os.path.join(itklibdir, "Release")
		itkpydir = os.path.join(itkpkg, "Python")
		itkpydir = os.path.join(itkpydir, "Release")
		sys.path.insert(0, itklibdir)
		sys.path.insert(0, itkpydir)
		path = os.getenv("PATH")
		path = path + os.path.pathsep + itklibdir
		os.putenv("PATH", path)

if scripting.main_is_frozen() and platform.system()=="Darwin":
	import site
	site.addsitedir(os.environ["RESOURCEPATH"]+"/InsightToolkit/WrapITK/Python")
	site.addsitedir(os.environ["RESOURCEPATH"]+"/InsightToolkit/WrapITK/lib")
	


# This will fix the VTK paths using either values from the
# configuration file, or sensible defaults

conffile = os.path.join(scripting.get_config_dir(), "BioImageXD.ini")
conf = Configuration.Configuration(conffile)

w = vtk.vtkOutputWindow()
i = w.GetInstance()