diff options
author | Nathan Lovato <nathan@gdquest.com> | 2019-09-08 13:18:55 +0300 |
---|---|---|
committer | Nathan Lovato <nathan@gdquest.com> | 2019-09-08 13:19:05 +0300 |
commit | 5f47151d1ebe879043025ea428e2715c05e4159d (patch) | |
tree | 5078973d12247cb4e64ce6324503aece5a17948a /power_sequencer/operators | |
parent | 6abd6330be9a1e26e19e267bd6517c85ecd9183f (diff) |
Power Sequencer: update to avoid breaking python module tests
Also fix minor bugs in the addon
Diffstat (limited to 'power_sequencer/operators')
7 files changed, 68 insertions, 75 deletions
diff --git a/power_sequencer/operators/__init__.py b/power_sequencer/operators/__init__.py index 7c1e0ca0..93519426 100644 --- a/power_sequencer/operators/__init__.py +++ b/power_sequencer/operators/__init__.py @@ -77,7 +77,6 @@ from .snap_selection import POWER_SEQUENCER_OT_snap_selection from .speed_remove_effect import POWER_SEQUENCER_OT_speed_remove_effect from .swap_strips import POWER_SEQUENCER_OT_swap_strips from .select_all_left_or_right import POWER_SEQUENCER_OT_select_all_left_or_right -from .synchronize_titles import POWER_SEQUENCER_OT_synchronize_titles from .toggle_selected_mute import POWER_SEQUENCER_OT_toggle_selected_mute from .toggle_waveforms import POWER_SEQUENCER_OT_toggle_waveforms from .trim_three_point_edit import POWER_SEQUENCER_OT_trim_three_point_edit @@ -146,7 +145,6 @@ classes = [ POWER_SEQUENCER_OT_snap_selection, POWER_SEQUENCER_OT_speed_remove_effect, POWER_SEQUENCER_OT_swap_strips, - POWER_SEQUENCER_OT_synchronize_titles, POWER_SEQUENCER_OT_toggle_selected_mute, POWER_SEQUENCER_OT_toggle_waveforms, POWER_SEQUENCER_OT_trim_three_point_edit, diff --git a/power_sequencer/operators/audiosync/find_offset.py b/power_sequencer/operators/audiosync/find_offset.py index a25bffde..90153e1a 100644 --- a/power_sequencer/operators/audiosync/find_offset.py +++ b/power_sequencer/operators/audiosync/find_offset.py @@ -20,7 +20,6 @@ This code is an adaptation of 'audio-offset-finder' by BBC import os import warnings import numpy as np -from scipy.io import wavfile from .mfcc import mfcc from .convert_and_trim import convert_and_trim @@ -36,6 +35,8 @@ def find_offset(file1, file2, freq=8000, trim=60 * 15, correl_nframes=1000): Uses cross-correlation of standardised Mel-Frequency Cepstral Coefficients """ + from scipy.io import wavfile + file1 = os.path.abspath(file1) file2 = os.path.abspath(file2) diff --git a/power_sequencer/operators/concatenate_strips.py b/power_sequencer/operators/concatenate_strips.py index 29d11384..4ef2407d 100644 --- a/power_sequencer/operators/concatenate_strips.py +++ b/power_sequencer/operators/concatenate_strips.py @@ -84,7 +84,7 @@ class POWER_SEQUENCER_OT_concatenate_strips(bpy.types.Operator): @classmethod def poll(cls, context): - return context.sequences and context.selected_sequences + return context.sequences def invoke(self, context, event): if not context.selected_sequences: diff --git a/power_sequencer/operators/import_local_footage.py b/power_sequencer/operators/import_local_footage.py index 8c8ca1ec..1f13b15d 100644 --- a/power_sequencer/operators/import_local_footage.py +++ b/power_sequencer/operators/import_local_footage.py @@ -152,7 +152,7 @@ class POWER_SEQUENCER_OT_import_local_footage(bpy.types.Operator): files = [f for f in sorted(files) if f.lower().endswith(EXTENSIONS_ALL)] files = map(lambda name: os.path.join(root, name), files) - files = map(lambda path: os.path.relpath(path, root), files) + files = map(lambda path: os.path.relpath(path, self.directory), files) files_list.extend(list(files)) return files_list diff --git a/power_sequencer/operators/render_presets/twitter_720p.py b/power_sequencer/operators/render_presets/twitter_720p.py index e7324d96..466646b5 100644 --- a/power_sequencer/operators/render_presets/twitter_720p.py +++ b/power_sequencer/operators/render_presets/twitter_720p.py @@ -14,34 +14,34 @@ # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <https://www.gnu.org/licenses/>. # -import bpy +if __name__ == "__main__": + import bpy -# Resolution -bpy.context.scene.render.resolution_x = 1280 -bpy.context.scene.render.resolution_y = 720 -bpy.context.scene.render.resolution_percentage = 100 -bpy.context.scene.render.pixel_aspect_x = 1 -bpy.context.scene.render.pixel_aspect_y = 1 + render = bpy.context.scene.render + render.resolution_x = 1280 + render.resolution_y = 720 + render.resolution_percentage = 100 + render.pixel_aspect_x = 1 + render.pixel_aspect_y = 1 -# FFMPEG -bpy.context.scene.render.image_settings.file_format = "FFMPEG" -bpy.context.scene.render.ffmpeg.format = "MPEG4" -bpy.context.scene.render.ffmpeg.codec = "H264" + # FFMPEG + render.image_settings.file_format = "FFMPEG" + render.ffmpeg.format = "MPEG4" + render.ffmpeg.codec = "H264" -bpy.context.scene.render.ffmpeg.constant_rate_factor = "HIGH" -bpy.context.scene.render.ffmpeg.ffmpeg_preset = "MEDIUM" + render.ffmpeg.constant_rate_factor = "HIGH" + render.ffmpeg.ffmpeg_preset = "BEST" + is_ntsc = render.fps != 25 + if is_ntsc: + render.ffmpeg.gopsize = 18 + else: + render.ffmpeg.gopsize = 15 + render.ffmpeg.use_max_b_frames = False -is_ntsc = bpy.context.scene.render.fps != 25 -if is_ntsc: - bpy.context.scene.render.ffmpeg.gopsize = 18 -else: - bpy.context.scene.render.ffmpeg.gopsize = 15 -bpy.context.scene.render.ffmpeg.use_max_b_frames = False - -bpy.context.scene.render.ffmpeg.video_bitrate = 4000 -bpy.context.scene.render.ffmpeg.maxrate = 4000 -bpy.context.scene.render.ffmpeg.minrate = 0 -bpy.context.scene.render.ffmpeg.buffersize = 224 * 8 -bpy.context.scene.render.ffmpeg.packetsize = 2048 -bpy.context.scene.render.ffmpeg.muxrate = 10080000 + render.ffmpeg.video_bitrate = 4000 + render.ffmpeg.maxrate = 4000 + render.ffmpeg.minrate = 0 + render.ffmpeg.buffersize = 224 * 8 + render.ffmpeg.packetsize = 2048 + render.ffmpeg.muxrate = 10080000 diff --git a/power_sequencer/operators/render_presets/youtube_1080.py b/power_sequencer/operators/render_presets/youtube_1080.py index 9aa98830..1b7940e2 100644 --- a/power_sequencer/operators/render_presets/youtube_1080.py +++ b/power_sequencer/operators/render_presets/youtube_1080.py @@ -14,34 +14,33 @@ # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <https://www.gnu.org/licenses/>. # -import bpy +if __name__ == "__main__": + import bpy -# Resolution -bpy.context.scene.render.resolution_x = 1920 -bpy.context.scene.render.resolution_y = 1080 -bpy.context.scene.render.resolution_percentage = 100 -bpy.context.scene.render.pixel_aspect_x = 1 -bpy.context.scene.render.pixel_aspect_y = 1 + render = bpy.context.scene.render + render.resolution_x = 1920 + render.resolution_y = 1080 + render.resolution_percentage = 100 + render.pixel_aspect_x = 1 + render.pixel_aspect_y = 1 -# FFMPEG -bpy.context.scene.render.image_settings.file_format = "FFMPEG" -bpy.context.scene.render.ffmpeg.format = "MPEG4" -bpy.context.scene.render.ffmpeg.codec = "H264" + render.image_settings.file_format = "FFMPEG" + render.ffmpeg.format = "MPEG4" + render.ffmpeg.codec = "H264" -bpy.context.scene.render.ffmpeg.constant_rate_factor = "PERC_LOSSLESS" -bpy.context.scene.render.ffmpeg.ffmpeg_preset = "GOOD" + render.ffmpeg.constant_rate_factor = "PERC_LOSSLESS" + render.ffmpeg.ffmpeg_preset = "BEST" + is_ntsc = render.fps != 25 + if is_ntsc: + render.ffmpeg.gopsize = 18 + else: + render.ffmpeg.gopsize = 15 + render.ffmpeg.use_max_b_frames = False -is_ntsc = bpy.context.scene.render.fps != 25 -if is_ntsc: - bpy.context.scene.render.ffmpeg.gopsize = 18 -else: - bpy.context.scene.render.ffmpeg.gopsize = 15 -bpy.context.scene.render.ffmpeg.use_max_b_frames = False - -bpy.context.scene.render.ffmpeg.video_bitrate = 9000 -bpy.context.scene.render.ffmpeg.maxrate = 9000 -bpy.context.scene.render.ffmpeg.minrate = 0 -bpy.context.scene.render.ffmpeg.buffersize = 224 * 8 -bpy.context.scene.render.ffmpeg.packetsize = 2048 -bpy.context.scene.render.ffmpeg.muxrate = 10080000 + render.ffmpeg.video_bitrate = 9000 + render.ffmpeg.maxrate = 9000 + render.ffmpeg.minrate = 0 + render.ffmpeg.buffersize = 224 * 8 + render.ffmpeg.packetsize = 2048 + render.ffmpeg.muxrate = 10080000 diff --git a/power_sequencer/operators/trim_to_surrounding_cuts.py b/power_sequencer/operators/trim_to_surrounding_cuts.py index 3f98cc8c..11ece536 100644 --- a/power_sequencer/operators/trim_to_surrounding_cuts.py +++ b/power_sequencer/operators/trim_to_surrounding_cuts.py @@ -30,13 +30,14 @@ from .utils.functions import ( class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): - """ - *Brief* Automatically trim to surrounding cuts with some time offset + """*Brief* Automatically trim to surrounding cuts with some time offset - Finds the two cuts closest to the mouse cursor and trims the footage in between, leaving a little time offset. It's useful after you removed some bad audio but you need to keep some video around for a transition. - By default, the tool leaves 0.2 a seconds margin on either side of the trim. - """ + Finds the two cuts closest to the mouse cursor and trims the footage in between, leaving a + little time offset. It's useful after you removed some bad audio but you need to keep some + video around for a transition. + By default, the tool leaves a 0.2 seconds margin on either side of the trim. + """ doc = { "name": doc_name(__qualname__), "demo": "", @@ -77,16 +78,13 @@ class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): sequencer = bpy.ops.sequencer - # Convert mouse position to frame, channel - x = context.region.view2d.region_to_view(x=event.mouse_region_x, y=event.mouse_region_y)[0] - frame = round(x) + frame = context.region.view2d.region_to_view(x=event.mouse_region_x, y=event.mouse_region_y)[0] + frame = round(frame) left_cut_frame, right_cut_frame = find_closest_surrounding_cuts_frames(context, frame) - surrounding_cut_frames_duration = abs(left_cut_frame - right_cut_frame) - margin_frame = convert_duration_to_frames(context, self.margin) - if surrounding_cut_frames_duration <= margin_frame * 2: + if abs(left_cut_frame - right_cut_frame) <= margin_frame * 2: self.report( {"WARNING"}, ("The trim margin is larger than the gap\n" "Use snap trim or reduce the margin"), @@ -124,13 +122,11 @@ class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): bpy.ops.power_sequencer.gap_remove() context.scene.frame_current = trim_start - # FIXME: Workaround Blender 2.80's audio bug, remove when fixed in Blender sequencer_workaround_2_80_audio_bug(context) - return {"FINISHED"} def find_strips_in_range( - self, context, start_frame, end_frame, sequences=None, find_overlapping=True + self, context, start_frame, end_frame, sequences=[], find_overlapping=True ): """ Returns strips which start and end within a certain frame range, or that overlap a @@ -149,11 +145,10 @@ class POWER_SEQUENCER_OT_trim_to_surrounding_cuts(bpy.types.Operator): """ strips_in_range = [] strips_overlapping_range = [] - if not sequences: - sequences = context.sequences + sequences = sequences if sequences else context.sequences for s in sequences: - if start_frame <= s.frame_final_start <= end_frame: - if start_frame <= s.frame_final_end <= end_frame: + if start_frame < s.frame_final_start <= end_frame: + if start_frame <= s.frame_final_end < end_frame: strips_in_range.append(s) elif find_overlapping: strips_overlapping_range.append(s) |