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
# if wxpython gets imported before vtk, the vtkExtTIFFReader will not read the olympus files
# DO NOT ask me why that is!
import vtk
import Configuration
import scripting
import Logging
import glob


try:
	import profile
except ImportError:
	profile = None
	

todir = scripting.get_main_dir()
if todir:
	os.chdir(todir)

if not todir:
	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)