示例#1
0
def main():
	""""Initialise common settings and check the operating environment before starting the application."""

	print "--------------------------------"
	print "   OpenShot (version %s)" % info.SETUP['version']
	print "--------------------------------"

	# only allow 1 instance of OpenShot to run
	from classes import lock
	lock.check_pid(os.path.join(os.path.expanduser("~"), ".openshot"))

	# import the locale, and set the locale. This is used for 
	# locale-aware number to string formatting
	locale.setlocale(locale.LC_ALL, '')

	# init threads - this helps support the 
	# multi-threaded architecture of mlt
	gtk.gdk.threads_init()
	gtk.gdk.threads_enter()

	# Create a default project object
	from classes import project
	current_project = project.project()

	# Create form object & refresh the data
	from windows import MainGTK
	form1 = MainGTK.frmMain(project=current_project, version=info.SETUP['version'])
	form1.refresh()

	# Main loop
	gtk.main()
示例#2
0
	def on_btnCreateProject_clicked(self, widget, *args):
		print "on_btnCreateProject_clicked called with self.%s" % widget.get_name()

		localName = str.strip(self.txtProjectName.get_text())
		localFolder = str.strip(self.fileProjectFolder.get_filename())
		localType = self.cmbProjectType.get_active_text()
		localLength = str.strip(self.spinProjectLength.get_text())

		# Validate the the form is valid
		if (len(localName) == 0):
			# Show error message
			messagebox.show(_("Validation Error!"), _("Please enter a valid project name."))

		elif (localType == - 1):
			# Show error message
			messagebox.show(_("Validation Error!"), _("Please enter a valid project type."))

		else:

			
			# check if mode is 'New Project'
			if (self.mode == "new"):
				# Re-init / clear the current project object (to reset all exisint data)
				self.project = project.project()
				self.project.form = self.form
				self.project.form.project = self.project
				
				# clear history (since we are opening a new project)
				self.project.form.history_stack = []
				self.project.form.history_index = -1
				self.project.form.refresh_history()
				self.project.set_project_modified(is_modified=True, refresh_xml=False, type=_("New project"))
			
			# set the project properties
			self.project.name = localName
			self.project.project_type = localType
			self.project.folder = localFolder
			self.project.sequences[0].length = float(localLength) * 60  # convert to seconds
			self.project.set_project_modified(is_modified=False, refresh_xml=True)

			# stop video
			self.project.form.MyVideo.pause()

			# set the profile settings in the video thread
			self.project.form.MyVideo.set_project(self.project, self.project.form, os.path.join(self.project.USER_DIR, "sequence.mlt"), mode="preview")
			self.project.form.MyVideo.set_profile(localType)
			self.project.form.MyVideo.load_xml()

			# Save the project
			self.project.Save("%s/%s.osp" % (localFolder, localName))

			# Is openshot existing?
			if self.project.form.is_exiting:
				self.project.form.frmMain.destroy()

			# Update the main form
			self.project.form.refresh()

			# close the window
			self.frmNewProject.destroy()
示例#3
0
def main():
    """"Initialise common settings and check the operating environment before starting the application."""

    # Display version and exit (if requested)
    if ("--version" in sys.argv):
        print "LibreShot version %s" % info.VERSION
        exit()

    print "--------------------------------"
    print "   LibreShot (version %s)" % info.SETUP['version']
    print "--------------------------------"

    # only allow 1 instance of LibreShot to run
    from classes import lock
    lock.check_pid(os.path.join(os.path.expanduser("~"), ".libreshot"))

    # import the locale, and set the locale. This is used for
    # locale-aware number to string formatting
    locale.setlocale(locale.LC_ALL, '')

    # init threads - this helps support the
    # multi-threaded architecture of mlt
    gtk.gdk.threads_init()
    gtk.gdk.threads_enter()

    # Create a default project object
    from classes import project
    current_project = project.project()

    # Create form object & refresh the data
    from windows.MainGTK import frmMain
    app = frmMain(project=current_project, version=info.SETUP['version'])
    app.refresh()
    app.run()
示例#4
0
    def create_project(self):

        localName = str.strip(self.txtProjectName.get_text())
        localFolder = str.strip(self.fileProjectFolder.get_filename())
        localType = self.cmbProjectType.get_active_text()

        # check if mode is 'New Project'
        if (self.mode == "new"):
            # Re-init / clear the current project object (to reset all exisint data)
            self.project = project.project()
            self.project.form = self.form
            self.project.form.project = self.project

            # clear history (since we are opening a new project)
            self.project.form.history_stack = []
            self.project.form.history_index = -1
            self.project.form.refresh_history()
            self.project.set_project_modified(is_modified=True,
                                              refresh_xml=False,
                                              type=_("New project"))

        # set the project properties
        self.project.name = localName
        self.project.project_type = localType  # set the mlt profile
        self.project.mlt_profile = None  # clear the cached mlt_profile object
        self.project.folder = localFolder
        self.project.set_project_modified(is_modified=False, refresh_xml=True)

        # stop video
        self.project.form.MyVideo.pause()

        # set the profile settings in the video thread
        self.project.form.MyVideo.set_project(self.project,
                                              self.project.form,
                                              os.path.join(
                                                  self.project.USER_DIR,
                                                  "sequence.mlt"),
                                              mode="preview")
        self.project.form.MyVideo.set_profile(localType, load_xml=True)
        self.project.form.MyVideo.seek(0)

        #start the autosave
        self.project.form.setup_autosave()

        # Save the project
        self.project.Save("%s/%s.osp" % (localFolder, localName))

        # Is libreshot existing?
        if self.project.form.is_exiting:
            self.project.form.frmMain.destroy()

        # Update the main form
        self.project.form.refresh()

        # close the window
        self.frmNewProject.destroy()
示例#5
0
	def create_project(self):
	
		localName = str.strip(self.txtProjectName.get_text())
		localFolder = str.strip(self.fileProjectFolder.get_filename())
		localType = self.cmbProjectType.get_active_text()
	
		# check if mode is 'New Project'
		if (self.mode == "new"):
			# Re-init / clear the current project object (to reset all exisint data)
			self.project = project.project()
			self.project.form = self.form
			self.project.form.project = self.project
		
			# clear history (since we are opening a new project)
			self.project.form.history_stack = []
			self.project.form.history_index = -1
			self.project.form.refresh_history()
			self.project.set_project_modified(is_modified=True, refresh_xml=False, type=_("New project"))
	
		# set the project properties
		self.project.name = localName
		self.project.project_type = localType	# set the mlt profile
		self.project.mlt_profile = None			# clear the cached mlt_profile object
		self.project.folder = localFolder
		self.project.set_project_modified(is_modified=False, refresh_xml=True)

		# stop video
		self.project.form.MyVideo.pause()

		# set the profile settings in the video thread
		self.project.form.MyVideo.set_project(self.project, self.project.form, os.path.join(self.project.USER_DIR, "sequence.mlt"), mode="preview")
		self.project.form.MyVideo.set_profile(localType, load_xml=True)
		self.project.form.MyVideo.seek(0)

		#start the autosave
		self.project.form.setup_autosave()

		# Save the project
		self.project.Save("%s/%s.osp" % (localFolder, localName))

		# Is openshot existing?
		if self.project.form.is_exiting:
			self.project.form.frmMain.destroy()

		# Update the main form
		self.project.form.refresh()

		# close the window
		self.frmNewProject.destroy()
示例#6
0
def main():
    from classes import lock
    lock.check_pid(os.path.join(os.path.expanduser("~"), ".openshot"))
    locale.setlocale(locale.LC_ALL, '')

    gtk.gdk.threads_init()
    gtk.gdk.threads_enter()

    from classes import project
    current_project = project.project()

    from windows.MainGTK import frmMain
    app = frmMain(project=current_project, version=info.SETUP['version'])

    return [app, app.frmMain]
示例#7
0
    def __init__(self, init_threads=True):

        # debug message/function control
        self.DEBUG = True

        # define common directories containing resources
        # get the base directory of the openshot installation for all future relative references
        # Note: don't rely on __file__ to be an absolute path. E.g., in the debugger (pdb) it will be
        # a relative path, so use os.path.abspath()
        self.BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
        self.UI_DIR = os.path.join(self.BASE_DIR, "openshot", "windows", "ui")
        self.IMAGE_DIR = os.path.join(self.BASE_DIR, "openshot", "images")
        self.LOCALE_DIR = os.path.join(self.BASE_DIR, "openshot", "locale")
        self.PROFILES_DIR = os.path.join(self.BASE_DIR, "openshot", "profiles")
        self.TRANSITIONS_DIR = os.path.join(self.BASE_DIR, "openshot", "transitions")
        self.EXPORT_PRESETS_DIR = os.path.join(self.BASE_DIR, "openshot", "export_presets")
        self.EFFECTS_DIR = os.path.join(self.BASE_DIR, "openshot", "effects")
        # location for per-session, per-user, files to be written/read to
        self.DESKTOP = os.path.join(os.path.expanduser("~"), "Desktop")
        self.USER_DIR = os.path.join(os.path.expanduser("~"), ".openshot")
        self.THEMES_DIR = os.path.join(self.BASE_DIR, "openshot", "themes")

        # only run the following code if we are really using
        # this project file...
        if init_threads:

            # Add language support
            translator = Language_Init.Translator(self)
            _ = translator.lang.gettext

            # use OptionParser to interpret commandline options
            parser = OptionParser(_("usage: %prog [options] inputfile.osp"))
            parser.add_option(
                "-o", "--outputfile", dest="FileName", default="temp", help=_("destination file-name"), metavar="FILE"
            )

            parser.add_option(
                "-F", "--folder", dest="ExportFolder", default=self.USER_DIR, help=_("export folder"), metavar="FOLDER"
            )

            parser.add_option(
                "-i",
                "--image-sequence",
                action="store_true",
                dest="IsImageSequence",
                default=False,
                help=_("export as image sequence"),
            )

            parser.add_option(
                "-v",
                "--video",
                action="store_true",
                dest="IsVideo",
                default=False,
                help=_("export as video or audio file"),
            )

            parser.add_option(
                "-f", "--format", type="string", dest="ImageFormat", default="avi", help=_("set video codec")
            )

            parser.add_option(
                "-C", "--video-codec", type="str", dest="VideoCodec", default="mpeg4", help=_("set video codec")
            )

            parser.add_option(
                "-R",
                "--video-bitrate",
                type="string",
                dest="VideoBitRate",
                default="5 Mb/s",
                help=_("set video bitrate in format 'number kb/s' or 'number Mb/s'"),
            )

            parser.add_option(
                "-c", "--audio-codec", type="string", dest="AudioCodec", default="libmp3lame", help=_("set audio codec")
            )

            parser.add_option(
                "-s",
                "--audio-samplerate",
                type="int",
                dest="SampleRate",
                default=44100,
                help=_("set audio sample rate"),
            )

            parser.add_option(
                "--channels", type="int", dest="Channels", default=2, help=_("set number of audio channels")
            )

            parser.add_option(
                "-r",
                "--audio-bitrate",
                type="string",
                dest="AudioBitRate",
                default="128 kb/s",
                help=_("set video bitrate in format 'number kb/s'"),
            )

            def error(message):
                """Prints an error message, the help message and quits"""
                global parser
                print _("Error: ") + message
                print
                sys.exit()

            def warn(message):
                """Print a warning message"""
                print _("Warning: ") + message

                # get optparse arguments and check for sanity

            (options, args) = parser.parse_args()

            if not args:
                parser.print_help()
                error(_("Please specify an input project-file!"))

            if len(args) > 1:
                parser.print_help()
                error(_("Too many arguments!"))

                # this is the file we want to parse
            self.inputscript = args[0]

            def convert_to_bytes(BitRateString):
                bit_rate_bytes = 0
                # split the string into pieces
                s = BitRateString.lower().split(" ")
                measurement = "kb"
                try:
                    # Get Bit Rate
                    if len(s) >= 2:
                        raw_number = float(s[0])
                        raw_measurement = s[1]
                        if "kb" in raw_measurement:
                            measurement = "kb"
                            # bit_rate_bytes = raw_number * 1024.0
                            bit_rate_bytes = raw_number * 1000.0
                        elif "mb" in raw_measurement:
                            measurement = "mb"
                            # bit_rate_bytes = raw_number * 1024.0 * 1024.0
                            bit_rate_bytes = raw_number * 1000.0 * 1000.0
                except:
                    pass
                    # return the bit rate in bytes
                return str(int(bit_rate_bytes))

                # consider the render options

            self.render_options = {}
            self.render_options["folder"] = options.ExportFolder
            self.render_options["file"] = options.FileName

            if options.IsImageSequence:
                self.render_options["vcodec"] = options.ImageFormat
                self.render_options["f"] = options.ImageFormat
                self.render_options["export_to"] = "Image Sequence"

            else:
                self.render_options["vcodec"] = options.VideoCodec
                self.render_options["f"] = options.ImageFormat
                self.render_options["export_to"] = ""

            self.render_options["b"] = convert_to_bytes(options.VideoBitRate)
            self.render_options["acodec"] = options.AudioCodec
            self.render_options["ar"] = options.SampleRate
            self.render_options["ac"] = options.Channels
            self.render_options["ab"] = convert_to_bytes(options.AudioBitRate)

            # Print rendering options to terminal
            print "\n"
            print _("rendering options:")
            print _("container type:") + " " + str(self.render_options["f"])
            print _("video codec:") + " " + str(self.render_options["vcodec"])
            print _("video bitrate:") + " " + str(self.render_options["b"]) + "\n"
            print _("audio codec:") + " " + str(self.render_options["acodec"])
            print _("audio sample rate:") + " " + str(self.render_options["ar"])
            print _("channels:") + " " + str(self.render_options["ac"])
            print _("audio bitrate:") + " " + str(self.render_options["ab"]) + "\n"

            # get the complete path to the new file
            self.folder1 = self.render_options["folder"]
            self.file1 = self.render_options["file"]
            self.export_path = "%s.%s" % (os.path.join(self.folder1, self.file1), self.render_options["f"])

            self.current_project = project.project()

            self.myFile = file(self.inputscript, "rb")
            self.current_project = pickle.load(self.myFile)
示例#8
0
	def __init__(self, init_threads=True):

		# debug message/function control
		self.DEBUG = True
		
		# define common directories containing resources
		# get the base directory of the libreshot installation for all future relative references
		# Note: don't rely on __file__ to be an absolute path. E.g., in the debugger (pdb) it will be
		# a relative path, so use os.path.abspath()
		self.BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
		self.UI_DIR = os.path.join(self.BASE_DIR, "libreshot", "windows", "ui")
		self.IMAGE_DIR = os.path.join(self.BASE_DIR, "libreshot", "images")
		self.LOCALE_DIR = os.path.join(self.BASE_DIR, "libreshot", "locale")
		self.PROFILES_DIR = os.path.join(self.BASE_DIR, "libreshot", "profiles")
		self.TRANSITIONS_DIR = os.path.join(self.BASE_DIR, "libreshot", "transitions")
		self.EXPORT_PRESETS_DIR = os.path.join(self.BASE_DIR, "libreshot", "export_presets")
		self.EFFECTS_DIR = os.path.join(self.BASE_DIR, "libreshot", "effects")
		# location for per-session, per-user, files to be written/read to
		self.DESKTOP = os.path.join(os.path.expanduser("~"), "Desktop")
		self.USER_DIR = os.path.join(os.path.expanduser("~"), ".libreshot")
		self.THEMES_DIR = os.path.join(self.BASE_DIR, "libreshot", "themes")

		# only run the following code if we are really using 
		# this project file... 
		if init_threads:

			# Add language support
			translator = Language_Init.Translator(self)
			_ = translator.lang.gettext
			
			# use OptionParser to interpret commandline options
			parser = OptionParser(_("usage: %prog [options] inputfile.osp"))
			parser.add_option("-o",
							"--outputfile",
							dest="FileName",
							default="temp",
							help=_("destination file-name"),
							metavar="FILE")
							
			parser.add_option("-F",
							"--folder",
							dest="ExportFolder",
							default=self.USER_DIR,
							help=_("export folder"),
							metavar="FOLDER")
							
			parser.add_option("-i",
							"--image-sequence",
							action="store_true",
							dest="IsImageSequence",
							default=False,
							help=_("export as image sequence")
							)
							
			parser.add_option("-v",
							"--video",
							action="store_true",
							dest="IsVideo",
							default=False,
							help=_("export as video or audio file"))				

			parser.add_option("-f",
							"--format",
							type="string",
							dest="ImageFormat",
							default="avi",
							help=_("set video codec"))

			parser.add_option("-C",
							"--video-codec",
							type="str",
							dest="VideoCodec",
							default="mpeg4",
							help=_("set video codec"))
							
			parser.add_option("-R",
							"--video-bitrate",
							type="string",
							dest="VideoBitRate",
							default="5 Mb/s",
							help=_("set video bitrate in format 'number kb/s' or 'number Mb/s'"))
							
			parser.add_option("-c",
							"--audio-codec",
							type="string",
							dest="AudioCodec",
							default="libmp3lame",
							help=_("set audio codec"))
							
			parser.add_option("-s",
							"--audio-samplerate",
							type="int",
							dest="SampleRate",
							default=44100,
							help=_("set audio sample rate"))

			parser.add_option(
							"--channels",
							type="int",
							dest="Channels",
							default=2,
							help=_("set number of audio channels"))

			parser.add_option("-r",
							"--audio-bitrate",
							type="string",
							dest="AudioBitRate",
							default="128 kb/s",
							help=_("set video bitrate in format 'number kb/s'"))


			def error(message):
				'''Prints an error message, the help message and quits'''
				global parser
				print _("Error: ") + message
				print
				sys.exit()

			def warn(message):
				'''Print a warning message'''
				print _("Warning: ") + message


			# get optparse arguments and check for sanity
			(options, args) = parser.parse_args()

			if not args:
				parser.print_help()
				error(_('Please specify an input project-file!'))

			if len(args) > 1:
				parser.print_help()
				error(_("Too many arguments!"))

			# this is the file we want to parse
			self.inputscript = args[0]
			
			
			def convert_to_bytes(BitRateString):
				bit_rate_bytes = 0
				# split the string into pieces
				s = BitRateString.lower().split(" ")
				measurement = "kb"
				try:
					# Get Bit Rate
					if len(s) >= 2:
						raw_number = float(s[0])
						raw_measurement = s[1]					
						if "kb" in raw_measurement:
							measurement = "kb"
							#bit_rate_bytes = raw_number * 1024.0
							bit_rate_bytes = raw_number * 1000.0						
						elif "mb" in raw_measurement:
							measurement = "mb"
							#bit_rate_bytes = raw_number * 1024.0 * 1024.0
							bit_rate_bytes = raw_number * 1000.0 * 1000.0
				except:
					pass
				# return the bit rate in bytes
				return str(int(bit_rate_bytes))			
			
			# consider the render options
			self.render_options = {}
			self.render_options["folder"] = options.ExportFolder
			self.render_options["file"] = options.FileName
			
			if options.IsImageSequence:
				self.render_options["vcodec"] = options.ImageFormat
				self.render_options["f"] = options.ImageFormat
				self.render_options["export_to"] = "Image Sequence"
				
			else:
				self.render_options["vcodec"] = options.VideoCodec
				self.render_options["f"] = options.ImageFormat
				self.render_options["export_to"] = ""
				
			self.render_options["b"] = convert_to_bytes(options.VideoBitRate)
			self.render_options["acodec"] = options.AudioCodec
			self.render_options["ar"] = options.SampleRate
			self.render_options["ac"] = options.Channels
			self.render_options["ab"] = convert_to_bytes(options.AudioBitRate)
			
			# Print rendering options to terminal
			print "\n"	
			print _("rendering options:")
			print _("container type:")+" "+str(self.render_options["f"])
			print _("video codec:")+" "+str(self.render_options["vcodec"])
			print _("video bitrate:")+" "+str(self.render_options["b"])+"\n"
			print _("audio codec:")+" "+str(self.render_options["acodec"])
			print _("audio sample rate:")+" "+str(self.render_options["ar"])
			print _("channels:")+" "+str(self.render_options["ac"])
			print _("audio bitrate:")+" "+str(self.render_options["ab"])+"\n"			
			
			# get the complete path to the new file
			self.folder1 = self.render_options["folder"]
			self.file1 = self.render_options["file"]
			self.export_path = "%s.%s" % (os.path.join(self.folder1, self.file1), self.render_options["f"])
			
			self.current_project = project.project()
			
			self.myFile = file(self.inputscript, "rb")
			self.current_project = pickle.load(self.myFile)