@@ -61,8 +61,7 @@ def __init__(self):
61
61
ui_util .init_ui (self )
62
62
63
63
# get translations
64
- app = get_app ()
65
- _ = app ._tr
64
+ _ = get_app ()._tr
66
65
67
66
# Get settings
68
67
self .s = settings .get_settings ()
@@ -92,10 +91,10 @@ def __init__(self):
92
91
self .delayed_fps_timer .stop ()
93
92
94
93
# Pause playback (to prevent crash since we are fixing to change the timeline's max size)
95
- app .window .actionPlay_trigger (None , force = "pause" )
94
+ get_app () .window .actionPlay_trigger (None , force = "pause" )
96
95
97
96
# Clear timeline preview cache (to get more available memory)
98
- app .window .timeline_sync .timeline .ClearAllCache ()
97
+ get_app () .window .timeline_sync .timeline .ClearAllCache ()
99
98
100
99
# Hide audio channels
101
100
self .lblChannels .setVisible (False )
@@ -106,41 +105,38 @@ def __init__(self):
106
105
openshot .Settings .Instance ().HIGH_QUALITY_SCALING = True
107
106
108
107
# Get the original timeline settings
109
- width = app .window .timeline_sync .timeline .info .width
110
- height = app .window .timeline_sync .timeline .info .height
111
- fps = app .window .timeline_sync .timeline .info .fps
112
- sample_rate = app .window .timeline_sync .timeline .info .sample_rate
113
- channels = app .window .timeline_sync .timeline .info .channels
114
- channel_layout = app .window .timeline_sync .timeline .info .channel_layout
115
-
116
- # No keyframe rescaling has happened yet (due to differences in FPS)
117
- self .keyframes_rescaled = False
108
+ width = get_app ().window .timeline_sync .timeline .info .width
109
+ height = get_app ().window .timeline_sync .timeline .info .height
110
+ fps = get_app ().window .timeline_sync .timeline .info .fps
111
+ sample_rate = get_app ().window .timeline_sync .timeline .info .sample_rate
112
+ channels = get_app ().window .timeline_sync .timeline .info .channels
113
+ channel_layout = get_app ().window .timeline_sync .timeline .info .channel_layout
118
114
119
115
# Create new "export" openshot.Timeline object
120
116
self .timeline = openshot .Timeline (width , height , openshot .Fraction (fps .num , fps .den ),
121
117
sample_rate , channels , channel_layout )
122
118
# Init various properties
123
- self .timeline .info .channel_layout = app .window .timeline_sync .timeline .info .channel_layout
124
- self .timeline .info .has_audio = app .window .timeline_sync .timeline .info .has_audio
125
- self .timeline .info .has_video = app .window .timeline_sync .timeline .info .has_video
126
- self .timeline .info .video_length = app .window .timeline_sync .timeline .info .video_length
127
- self .timeline .info .duration = app .window .timeline_sync .timeline .info .duration
128
- self .timeline .info .sample_rate = app .window .timeline_sync .timeline .info .sample_rate
129
- self .timeline .info .channels = app .window .timeline_sync .timeline .info .channels
119
+ self .timeline .info .channel_layout = get_app () .window .timeline_sync .timeline .info .channel_layout
120
+ self .timeline .info .has_audio = get_app () .window .timeline_sync .timeline .info .has_audio
121
+ self .timeline .info .has_video = get_app () .window .timeline_sync .timeline .info .has_video
122
+ self .timeline .info .video_length = get_app () .window .timeline_sync .timeline .info .video_length
123
+ self .timeline .info .duration = get_app () .window .timeline_sync .timeline .info .duration
124
+ self .timeline .info .sample_rate = get_app () .window .timeline_sync .timeline .info .sample_rate
125
+ self .timeline .info .channels = get_app () .window .timeline_sync .timeline .info .channels
130
126
131
127
# Load the "export" Timeline reader with the JSON from the real timeline
132
- json_timeline = json .dumps (app .project ._data )
128
+ json_timeline = json .dumps (get_app () .project ._data )
133
129
self .timeline .SetJson (json_timeline )
134
130
135
131
# Open the "export" Timeline reader
136
132
self .timeline .Open ()
137
133
138
134
# Default export path
139
135
recommended_path = os .path .join (info .HOME_PATH )
140
- if app .project .current_filepath :
141
- recommended_path = os .path .dirname (app .project .current_filepath )
136
+ if get_app () .project .current_filepath :
137
+ recommended_path = os .path .dirname (get_app () .project .current_filepath )
142
138
143
- export_path = app .project .get ("export_path" )
139
+ export_path = get_app () .project .get ("export_path" )
144
140
if export_path and os .path .exists (export_path ):
145
141
# Use last selected export path
146
142
self .txtExportFolder .setText (export_path )
@@ -149,13 +145,13 @@ def __init__(self):
149
145
self .txtExportFolder .setText (recommended_path )
150
146
151
147
# Is this a saved project?
152
- if not app .project .current_filepath :
148
+ if not get_app () .project .current_filepath :
153
149
# Not saved yet
154
150
self .txtFileName .setText (_ ("Untitled Project" ))
155
151
else :
156
152
# Yes, project is saved
157
153
# Get just the filename
158
- filename = os .path .basename (app .project .current_filepath )
154
+ filename = os .path .basename (get_app () .project .current_filepath )
159
155
filename = os .path .splitext (filename )[0 ]
160
156
self .txtFileName .setText (filename )
161
157
@@ -191,7 +187,7 @@ def __init__(self):
191
187
self .cboSimpleQuality .currentIndexChanged .connect (
192
188
functools .partial (self .cboSimpleQuality_index_changed , self .cboSimpleQuality ))
193
189
self .cboChannelLayout .currentIndexChanged .connect (self .updateChannels )
194
- app .window .ExportFrame .connect (self .updateProgressBar )
190
+ get_app () .window .ExportFrame .connect (self .updateProgressBar )
195
191
196
192
# ********* Advanced Profile List **********
197
193
# Loop through profiles
@@ -220,7 +216,7 @@ def __init__(self):
220
216
self .cboProfile .addItem (self .getProfileName (self .getProfilePath (profile_name )), self .getProfilePath (profile_name ))
221
217
222
218
# Set default (if it matches the project)
223
- if app .project .get (['profile' ]) in profile_name :
219
+ if get_app () .project .get (['profile' ]) in profile_name :
224
220
self .selected_profile_index = box_index
225
221
226
222
# increment item counter
@@ -251,7 +247,7 @@ def __init__(self):
251
247
252
248
253
249
# Populate all profiles
254
- self .populateAllProfiles (app .project .get (['profile' ]))
250
+ self .populateAllProfiles (get_app () .project .get (['profile' ]))
255
251
256
252
# Connect framerate signals
257
253
self .txtFrameRateNum .valueChanged .connect (self .updateFrameRate )
@@ -368,8 +364,7 @@ def cboSimpleProjectType_index_changed(self, widget, index):
368
364
self .cboSimpleTarget .clear ()
369
365
370
366
# get translations
371
- app = get_app ()
372
- _ = app ._tr
367
+ _ = get_app ()._tr
373
368
374
369
# parse the xml files and get targets that match the project type
375
370
project_types = []
@@ -424,8 +419,7 @@ def cboProfile_index_changed(self, widget, index):
424
419
log .info (selected_profile_path )
425
420
426
421
# get translations
427
- app = get_app ()
428
- _ = app ._tr
422
+ _ = get_app ()._tr
429
423
430
424
# Load profile
431
425
profile = openshot .Profile (selected_profile_path )
@@ -454,8 +448,7 @@ def cboSimpleTarget_index_changed(self, widget, index):
454
448
log .info (selected_target )
455
449
456
450
# get translations
457
- app = get_app ()
458
- _ = app ._tr
451
+ _ = get_app ()._tr
459
452
460
453
# don't do anything if the combo has been cleared
461
454
if selected_target :
@@ -594,8 +587,7 @@ def cboSimpleQuality_index_changed(self, widget, index):
594
587
log .info (selected_quality )
595
588
596
589
# get translations
597
- app = get_app ()
598
- _ = app ._tr
590
+ _ = get_app ()._tr
599
591
600
592
# Set the video and audio bitrates
601
593
if selected_quality :
@@ -606,8 +598,7 @@ def btnBrowse_clicked(self):
606
598
log .info ("btnBrowse_clicked" )
607
599
608
600
# get translations
609
- app = get_app ()
610
- _ = app ._tr
601
+ _ = get_app ()._tr
611
602
612
603
# update export folder path
613
604
file_path = QFileDialog .getExistingDirectory (self , _ ("Choose a Folder..." ), self .txtExportFolder .text ())
@@ -677,8 +668,7 @@ def accept(self):
677
668
""" Start exporting video """
678
669
679
670
# get translations
680
- app = get_app ()
681
- _ = app ._tr
671
+ _ = get_app ()._tr
682
672
683
673
# Init progress bar
684
674
self .progressExportVideo .setMinimum (self .txtStartFrame .value ())
@@ -782,9 +772,9 @@ def accept(self):
782
772
video_settings ["vcodec" ] = image_ext
783
773
784
774
# Store updated export folder path in project file
785
- app .updates .update_untracked (["export_path" ], os .path .dirname (export_file_path ))
775
+ get_app () .updates .update_untracked (["export_path" ], os .path .dirname (export_file_path ))
786
776
# Mark project file as unsaved
787
- app .project .has_unsaved_changes = True
777
+ get_app () .project .has_unsaved_changes = True
788
778
789
779
# Set MaxSize (so we don't have any downsampling)
790
780
self .timeline .SetMaxSize (video_settings .get ("width" ), video_settings .get ("height" ))
@@ -793,14 +783,13 @@ def accept(self):
793
783
export_cache_object = openshot .CacheMemory (500 )
794
784
self .timeline .SetCache (export_cache_object )
795
785
796
- # Rescale all keyframes and reload project
786
+ # Rescale all keyframes (if needed)
797
787
if self .export_fps_factor != 1.0 :
798
- self . keyframes_rescaled = True
799
- app .project .rescale_keyframes (self .export_fps_factor )
788
+ # Get a copy of rescaled project data (this does not modify the active project)
789
+ rescaled_app_data = get_app () .project .rescale_keyframes (self .export_fps_factor )
800
790
801
791
# Load the "export" Timeline reader with the JSON from the real timeline
802
- json_timeline = json .dumps (app .project ._data )
803
- self .timeline .SetJson (json_timeline )
792
+ self .timeline .SetJson (json .dumps (rescaled_app_data ))
804
793
805
794
# Re-update the timeline FPS again (since the timeline just got clobbered)
806
795
self .updateFrameRate ()
@@ -853,7 +842,7 @@ def accept(self):
853
842
854
843
# Notify window of export started
855
844
title_message = ""
856
- app .window .ExportStarted .emit (export_file_path , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ))
845
+ get_app () .window .ExportStarted .emit (export_file_path , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ))
857
846
858
847
progressstep = max (1 , round (( video_settings .get ("end_frame" ) - video_settings .get ("start_frame" ) ) / 1000 ))
859
848
start_time_export = time .time ()
@@ -874,7 +863,7 @@ def accept(self):
874
863
'fps' : fps_encode }
875
864
876
865
# Emit frame exported
877
- app .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ), frame )
866
+ get_app () .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ), video_settings .get ("end_frame" ), frame )
878
867
879
868
# Process events (to show the progress bar moving)
880
869
QCoreApplication .processEvents ()
@@ -897,7 +886,7 @@ def accept(self):
897
886
'seconds' : seconds_run % 60 ,
898
887
'fps' : fps_encode }
899
888
900
- app .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ),
889
+ get_app () .window .ExportFrame .emit (title_message , video_settings .get ("start_frame" ),
901
890
video_settings .get ("end_frame" ), frame )
902
891
903
892
except Exception as e :
@@ -936,7 +925,7 @@ def accept(self):
936
925
msg .exec_ ()
937
926
938
927
# Notify window of export started
939
- app .window .ExportEnded .emit (export_file_path )
928
+ get_app () .window .ExportEnded .emit (export_file_path )
940
929
941
930
# Close timeline object
942
931
self .timeline .Close ()
@@ -986,10 +975,6 @@ def reject(self):
986
975
# Return scale mode to lower quality scaling (for faster previews)
987
976
openshot .Settings .Instance ().HIGH_QUALITY_SCALING = False
988
977
989
- # Return keyframes to preview scaling
990
- if self .keyframes_rescaled :
991
- get_app ().project .rescale_keyframes (self .original_fps_factor )
992
-
993
978
# Cancel dialog
994
979
self .exporting = False
995
980
super (Export , self ).reject ()
0 commit comments