31 from copy
import deepcopy
32 from classes
import info
33 from classes.app
import get_app
34 from classes.logger
import log
35 from classes
import settings
46 clip = openshot.Clip(file_path)
50 clip.Reader().info.has_video =
False
52 log.info(
"Clip loaded, start thread")
53 t = threading.Thread(target=get_waveform_thread, args=[clip, clip_id, file_path, channel_filter, volume_keyframe])
60 sample_rate = clip.Reader().info.sample_rate
63 samples_per_second = 20
64 sample_divisor = round(sample_rate / samples_per_second)
65 log.info(
"Getting waveform for sample rate: %s" % sample_rate)
68 for frame_number
in range(1, clip.Reader().info.video_length):
70 frame = clip.Reader().GetFrame(frame_number)
75 volume = volume_keyframe.GetValue(frame_number)
80 magnitude_range = sample_divisor
81 if sample + magnitude_range > frame.GetAudioSamplesCount():
82 magnitude_range = frame.GetAudioSamplesCount() - sample
85 if sample < frame.GetAudioSamplesCount():
86 audio_data.append(frame.GetAudioSample(channel_filter, sample, magnitude_range) * volume)
89 sample = max(0, sample - frame.GetAudioSamplesCount())
93 sample += sample_divisor
99 log.info(
"get_waveform_thread completed")
100 get_app().window.WaveformReady.emit(clip_id, audio_data)
def get_app
Returns the current QApplication instance of OpenShot.
def get_settings
Get the current QApplication's settings instance.