def run(self): global frames_cache frame_levels = [None] * self.clip_media_length frames_cache[self.clip.path] = frame_levels gtk.gdk.threads_enter() self.dialog.progress_bar.set_fraction(0.0) self.dialog.progress_bar.set_text(str(0) + "%") while (gtk.events_pending()): gtk.main_iteration() gtk.gdk.threads_leave() time.sleep(0.2) for frame in range(0, len(frame_levels)): if self.abort: break self.temp_clip.seek(frame) mlt.frame_get_waveform(self.temp_clip.get_frame(), 10, 50) val = self.levels.get(RIGHT_CHANNEL) if val == None: val = 0.0 frame_levels[frame] = float(val) self.last_rendered_frame = frame if frame % 500 == 0: render_fraction = float(self.last_rendered_frame) / float( self.clip_media_length) gtk.gdk.threads_enter() self.dialog.progress_bar.set_fraction(render_fraction) pros = int(render_fraction * 100) self.dialog.progress_bar.set_text(str(pros) + "%") while (gtk.events_pending()): gtk.main_iteration() gtk.gdk.threads_leave() time.sleep(0.1) if not self.abort: self.clip.waveform_data = frame_levels write_file = file(self.file_cache_path, "wb") pickle.dump(frame_levels, write_file) gtk.gdk.threads_enter() self.dialog.progress_bar.set_fraction(1.0) self.dialog.progress_bar.set_text(_("Saving to Hard Drive")) gtk.gdk.threads_leave() else: frames_cache.pop(self.clip.path, None) updater.repaint_tline() # Set thread ref to None to flag that no waveforms are being created global waveform_thread waveform_thread = None _waveform_render_stop(self.dialog, None)
def run(self): global frames_cache frame_levels = [None] * self.clip_media_length frames_cache[self.clip.path] = frame_levels Gdk.threads_enter() self.dialog.progress_bar.set_fraction(0.0) self.dialog.progress_bar.set_text(str(0) + "%") while(Gtk.events_pending()): Gtk.main_iteration() Gdk.threads_leave() time.sleep(0.2) for frame in range(0, len(frame_levels)): if self.abort: break self.temp_clip.seek(frame) mlt.frame_get_waveform(self.temp_clip.get_frame(), 10, 50) val = self.levels.get(RIGHT_CHANNEL) if val == None: val = 0.0 frame_levels[frame] = float(val) self.last_rendered_frame = frame if frame % 500 == 0: render_fraction = float(self.last_rendered_frame) / float(self.clip_media_length) Gdk.threads_enter() self.dialog.progress_bar.set_fraction(render_fraction) pros = int(render_fraction * 100) self.dialog.progress_bar.set_text(str(pros) + "%") while(Gtk.events_pending()): Gtk.main_iteration() Gdk.threads_leave() time.sleep(0.1) if not self.abort: self.clip.waveform_data = frame_levels write_file = file(self.file_cache_path, "wb") pickle.dump(frame_levels, write_file) Gdk.threads_enter() self.dialog.progress_bar.set_fraction(1.0) self.dialog.progress_bar.set_text(_("Saving to Hard Drive")) Gdk.threads_leave() else: frames_cache.pop(self.clip.path, None) updater.repaint_tline() # Set thread ref to None to flag that no waveforms are being created global waveform_thread waveform_thread = None _waveform_render_stop(self.dialog, None)
def run(self): frame_levels = [None] * self.clip_media_length for frame in range(0, len(frame_levels)): self.temp_clip.seek(frame) mlt.frame_get_waveform(self.temp_clip.get_frame(), 10, 50) val = self.levels.get(RIGHT_CHANNEL) if val == None: val = 0.0 frame_levels[frame] = float(val) self.last_rendered_frame = frame write_file = file(self.file_cache_path, "wb") pickle.dump(frame_levels, write_file)
#!/usr/bin/env python # -*- coding: utf-8 -*- import mlt from PIL import Image mlt.Factory.init() profile = mlt.Profile() prod = mlt.Producer(profile, "test.wav") size = (320, 240) for i in range(0, prod.get_length()): frm = prod.get_frame() wav = mlt.frame_get_waveform(frm, size[0], size[1]) img = Image.fromstring("L", size, wav) img.save("test-%04d.pgm" % (i))