def render_single_track_transition_clip(transition_producer, encoding_option_index, quality_option_index, file_ext, transition_render_complete_cb, window_text): # Set render complete callback to availble render stop callback using global variable global transition_render_done_callback transition_render_done_callback = transition_render_complete_cb # Profile profile = PROJECT().profile folder = userfolders.get_render_dir() file_name = md5.new(str(os.urandom(32))).hexdigest() write_file = folder + "/"+ file_name + file_ext # Render consumer consumer = renderconsumer.get_render_consumer_for_encoding_and_quality(write_file, profile, encoding_option_index, quality_option_index) # start and end frames start_frame = 0 end_frame = transition_producer.get_length() - 1 # Launch render # TODO: fix naming, this isn't motion renderer global motion_renderer, motion_progress_update motion_renderer = renderconsumer.FileRenderPlayer(write_file, transition_producer, consumer, start_frame, end_frame) motion_renderer.start() title = _("Rendering Transition Clip") progress_bar = Gtk.ProgressBar() dialog = rendergui.clip_render_progress_dialog(_transition_render_stop, title, window_text, progress_bar, gui.editor_window.window) motion_progress_update = renderconsumer.ProgressWindowThread(dialog, progress_bar, motion_renderer, _transition_render_stop) motion_progress_update.start()
def _get_disk_dir_panels(): panels = [] panels.append( DiskFolderManagementPanel(userfolders.get_cache_dir(), appconsts.AUDIO_LEVELS_DIR, _("Audio Levels Data"), RECREATE_WARNING)) panels.append( DiskFolderManagementPanel(userfolders.get_cache_dir(), appconsts.GMIC_DIR, _("G'Mic Tool Session Data"), NO_WARNING)) panels.append( DiskFolderManagementPanel(userfolders.get_data_dir(), appconsts.RENDERED_CLIPS_DIR, _("Rendered Files"), PROJECT_DATA_WARNING)) panels.append( DiskFolderManagementPanel(userfolders.get_render_dir(), "/" + appconsts.PROXIES_DIR, _("Proxy Files"), PROJECT_DATA_WARNING)) panels.append( DiskFolderManagementPanel(userfolders.get_cache_dir(), appconsts.THUMBNAILS_DIR, _("Thumbnails"), RECREATE_WARNING)) panels.append( DiskFolderManagementPanel(userfolders.get_data_dir(), appconsts.USER_PROFILES_DIR_NO_SLASH, _("User Created Custom Profiles"), PROJECT_DATA_WARNING)) return panels
def _create_img_seg_proxy_path(self, proxy_width, proxy_height): folder, file_name = os.path.split(self.path) proxy_md_key = self.path + str(proxy_width) + str(proxy_height) if hasattr(self, "use_unique_proxy"): # This may have been added in proxyediting.py to prevent interfering with existing projects proxy_md_key = proxy_md_key + os.urandom(16) md_str = hashlib.md5(proxy_md_key.encode('utf-8')).hexdigest() return str(userfolders.get_render_dir() + "/"+ appconsts.PROXIES_DIR + md_str + "/" + file_name)
def _create_img_seg_proxy_path(self, proxy_width, proxy_height): folder, file_name = os.path.split(self.path) proxy_md_key = self.path + str(proxy_width) + str(proxy_height) if hasattr(self, "use_unique_proxy"): # This may have been added in proxyediting.py to prevent interfering with existing projects proxy_md_key = proxy_md_key + os.urandom(16) md_str = md5.new(proxy_md_key).hexdigest() return str(userfolders.get_render_dir() + "/proxies/" + md_str + "/" + file_name)
def create_proxy_path(self, proxy_width, proxy_height, file_extesion): if self.type == appconsts.IMAGE_SEQUENCE: return self._create_img_seg_proxy_path(proxy_width, proxy_height) proxy_md_key = self.path + str(proxy_width) + str(proxy_height) if hasattr(self, "use_unique_proxy"): # This may have been added in proxyediting.py to prevent interfering with existing projects proxy_md_key = proxy_md_key + str(os.urandom(16)) md_str = hashlib.md5(proxy_md_key.encode('utf-8')).hexdigest() return str(userfolders.get_render_dir() + "/proxies/" + md_str + "." + file_extesion) # str() because we get unicode here
def create_proxy_path(self, proxy_width, proxy_height, file_extesion): if self.type == appconsts.IMAGE_SEQUENCE: return self._create_img_seg_proxy_path(proxy_width, proxy_height) proxy_md_key = self.path + str(proxy_width) + str(proxy_height) if hasattr(self, "use_unique_proxy"): # This may have been added in proxyediting.py to prevent interfering with existing projects proxy_md_key = proxy_md_key + os.urandom(16) md_str = md5.new(proxy_md_key).hexdigest() return str(userfolders.get_render_dir() + "/proxies/" + md_str + "." + file_extesion) # str() because we get unicode here
def _do_create_sync_compound_clip(dialog, response_id, data): if response_id != Gtk.ResponseType.ACCEPT: dialog.destroy() return sync_data, name_entry = data files_offsets, clips = sync_data video_file, audio_file, idstr = clips media_name = name_entry.get_text() dialog.destroy() # Create unique file path in hidden render folder folder = userfolders.get_render_dir() uuid_str = hashlib.md5(str(os.urandom(32)).encode('utf-8')).hexdigest() write_file = folder + "/" + uuid_str + ".xml" # Create tractor tractor = mlt.Tractor() multitrack = tractor.multitrack() track_video = mlt.Playlist() track_audio = mlt.Playlist() track_audio.set("hide", 1) # video off, audio on as mlt "hide" value multitrack.connect(track_audio, 0) multitrack.connect(track_video, 0) # Create clips video_clip = mlt.Producer(PROJECT().profile, str(video_file)) audio_clip = mlt.Producer(PROJECT().profile, str(audio_file)) # Get offset offset = float(files_offsets[audio_file]) print(audio_file, offset) # Add clips if offset > 0: offset_frames = int(float(offset) + 0.5) track_video.append(video_clip, 0, video_clip.get_length() - 1) track_audio.insert_blank(0, offset_frames) track_audio.append(audio_clip, 0, audio_clip.get_length() - 1) elif offset < 0: offset_frames = int(float(offset) - 0.5) track_video.insert_blank(0, offset_frames) track_video.append(video_clip, 0, video_clip.get_length() - 1) track_audio.append(audio_clip, 0, audio_clip.get_length() - 1) else: track_video.append(video_clip, 0, video_clip.get_length() - 1) track_audio.append(audio_clip, 0, audio_clip.get_length() - 1) # render MLT XML, callback in projectaction.py creates media object render_player = renderconsumer.XMLCompoundRenderPlayer( write_file, media_name, projectaction._xml_compound_render_done_callback, tractor, PROJECT()) render_player.start()
def _do_create_sync_compound_clip(dialog, response_id, data): if response_id != Gtk.ResponseType.ACCEPT: dialog.destroy() return sync_data, name_entry = data files_offsets, clips = sync_data video_file, audio_file, idstr = clips media_name = name_entry.get_text() dialog.destroy() # Create unique file path in hidden render folder folder = userfolders.get_render_dir() uuid_str = md5.new(str(os.urandom(32))).hexdigest() write_file = folder + "/"+ uuid_str + ".xml" # Create tractor tractor = mlt.Tractor() multitrack = tractor.multitrack() track_video = mlt.Playlist() track_audio = mlt.Playlist() track_audio.set("hide", 1) # video off, audio on as mlt "hide" value multitrack.connect(track_audio, 0) multitrack.connect(track_video, 0) # Create clips video_clip = mlt.Producer(PROJECT().profile, str(video_file)) audio_clip = mlt.Producer(PROJECT().profile, str(audio_file)) # Get offset offset = files_offsets[audio_file] print audio_file, offset # Add clips if offset > 0: offset_frames = int(float(offset) + 0.5) track_video.append(video_clip, 0, video_clip.get_length() - 1) track_audio.insert_blank(0, offset_frames) track_audio.append(audio_clip, 0, audio_clip.get_length() - 1) elif offset < 0: offset_frames = int(float(offset) - 0.5) track_video.insert_blank(0, offset_frames) track_video.append(video_clip, 0, video_clip.get_length() - 1) track_audio.append(audio_clip, 0, audio_clip.get_length() - 1) else: track_video.append(video_clip, 0, video_clip.get_length() - 1) track_audio.append(audio_clip, 0, audio_clip.get_length() - 1) # render MLT XML, callback in projectaction.py creates media object render_player = renderconsumer.XMLCompoundRenderPlayer(write_file, media_name, projectaction._xml_compound_render_done_callback, tractor) render_player.start()
def create_mlt_producer(self, profile): width = profile.width() height = profile.height() surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) cr = cairo.Context(surface) cr.set_source_rgb(*utils.gdk_color_str_to_cairo_rgb(self.gdk_color_str)) cr.rectangle(0, 0, width + 1, height+ 1) cr.fill() file_name = hashlib.md5((self.gdk_color_str + str(width) + str(height)).encode('utf-8')).hexdigest() write_file_path = userfolders.get_render_dir() + "/" + file_name + ".png" surface.write_to_png(write_file_path) producer = mlt.Producer(profile, write_file_path) mltrefhold.hold_ref(producer) return producer
def create_mlt_producer(self, profile): width = profile.width() height = profile.height() surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) cr = cairo.Context(surface) cr.set_source_rgb(*utils.gdk_color_str_to_cairo_rgb(self.gdk_color_str)) cr.rectangle(0, 0, width + 1, height+ 1) cr.fill() file_name = md5.new(self.gdk_color_str + str(width) + str(height)).hexdigest() write_file_path = userfolders.get_render_dir() + "/" + file_name + ".png" surface.write_to_png(write_file_path) producer = mlt.Producer(profile, write_file_path) mltrefhold.hold_ref(producer) return producer
def _save_changed_xml_file(s_media_file, new_profile): xml_file = open(s_media_file.path) xml_text = xml_file.read() new_profile_node = mltprofiles.get_profile_node(new_profile) in_index = xml_text.find("<profile") out_index = xml_text.find("/>", in_index) + 2 new_xml_text = xml_text[0:in_index] + new_profile_node + xml_text[out_index:len(xml_text)] folder = userfolders.get_render_dir() uuid_str = hashlib.md5(str(os.urandom(32)).encode('utf-8')).hexdigest() new_xml_file_path = folder + "/"+ uuid_str + ".xml" with atomicfile.AtomicFileWriter(new_xml_file_path, "w") as afw: new_xml_file = afw.get_file() new_xml_file.write(new_xml_text) return new_xml_file_path
def _save_changed_xml_file(s_media_file, new_profile): xml_file = open(s_media_file.path) xml_text = xml_file.read() new_profile_node = mltprofiles.get_profile_node(new_profile) in_index = xml_text.find("<profile") out_index = xml_text.find("/>", in_index) + 2 new_xml_text = xml_text[0:in_index] + new_profile_node + xml_text[out_index:len(xml_text)] folder = userfolders.get_render_dir() uuid_str = md5.new(str(os.urandom(32))).hexdigest() new_xml_file_path = folder + "/"+ uuid_str + ".xml" with atomicfile.AtomicFileWriter(new_xml_file_path, "w") as afw: new_xml_file = afw.get_file() new_xml_file.write(new_xml_text) return new_xml_file_path
def run(self): self.start_time = time.monotonic() new_media_file_name = hashlib.md5(str(os.urandom(32)).encode('utf-8') + str.encode(self.file_name)).hexdigest() link_path_no_ext = userfolders.get_render_dir() + "/" + new_media_file_name if self.media_asset.media_type == appconsts.IMAGE: link_path = link_path_no_ext + ".png" self.success = background_missing_image(link_path, self.file_name) elif self.media_asset.media_type == appconsts.AUDIO: link_path = link_path_no_ext + ".wav" self.success = sine_wav(link_path, self.media_asset.length) elif self.media_asset.media_type == appconsts.VIDEO: link_path = link_path_no_ext + ".mp4" self.success = video_file_replace(link_path, self.file_name, self.media_asset.length) self.media_asset.relink_path = link_path self.running = False
def _get_proxies_dir(): return userfolders.get_render_dir() + "/proxies"
def _get_proxies_dir(): return userfolders.get_render_dir() + appconsts.PROXIES_DIR