def playblast_with_settings(viewport_preset=None, viewport_preset_yaml=None, **recArgs): ''' Playblast with the user-defined settings recArgs are the arguments needed for the capture command ''' # get default viewport preset config if viewport_preset and viewport_preset_yaml: cache_file = path.get_config_yaml(viewport_preset_yaml) viewportArgs = database.read_cache(viewport_preset, cache_file) else: viewportArgs = {} # process filenames filepath = recArgs["filename"] if not filepath: filepath = path.get_default_playblast_folder() filepath = path.sanitize(filepath) filepath_with_ext = add_extension(filepath, recArgs) if is_file_on_disk( filepath_with_ext) and not recArgs.get("force_overwrite"): filename = os.path.split(filepath_with_ext)[-1] message = '[{}] already exists.\nDo you want to replace it?'.format( filename) if not confirm_overwrite_dialogue(message) == 'yes': return recArgs["show_ornaments"] = False recArgs["viewer"] = False # merge with viewport args viewport_options = viewportArgs.copy() viewport_options.update(recArgs) logger.info("viewport_options: {}".format(viewport_options)) playblast_file = capture.capture(**viewport_options) if playblast_file: playblast_file = add_extension(playblast_file, recArgs) recArgs["filename"] = playblast_file database.save_last_recorded(recArgs) database.dump_cache({"last_recorded_selection": playblast_file}) logger.info('Find your recorded file here: {}'.format(playblast_file)) return playblast_file else: logger.info("playblast_with_settings failed")
def playblast(filepath = None, width = 1280, height = 720, start_frame = 0, end_frame = 0, view_afterward = False, force_overwrite=False): ''' Playblast with the pre-defined settings based on the user's OS ''' logger.info("Playblast this:") if not filepath: filepath = path.get_default_playblast_folder() if filepath: filepath = path.sanitize(filepath) if os.path.isfile(filepath) and not force_overwrite: filename = os.path.split(filepath)[-1] message = '[{}] already exists.\nDo you want to replace it?'.format(filename) if not confirm_overwrite_dialogue(message) == 'yes': return recArgs = { "width": width, "height": height, "start_frame": start_frame, "end_frame": end_frame } logger.info("recargsplayblast (): {}".format(recArgs)) # record with OS specific Fallback Settings os_settings = { "darwin": [ { "format": 'qt', "compression": 'H.264', }, { "format": 'avfoundation', "compression": 'H.264', } ], "linux2": [ { "format": 'movie', "compression": 'H.264', }, { "format": 'movie', "compression": '', } ], "linux2": [ { "win32": 'qt', "compression": 'H.264', }, { "format": 'movie', "compression": '', } ] } for platform, settingsList in os_settings.iteritems(): if sys.platform == platform: for setting in settingsList: recArgs["compression"] = setting["compression"] try: logger.info("recArgs playblast(): {}".format(**recArgs)) playblast_file = _playblast_with_settings(**recArgs) return playblast_file except Exception as err: logger.info(u'%s' %(err))