@@ -261,43 +261,16 @@ def relative_path(self):
261
261
262
262
def profile (self ):
263
263
""" Get the profile of the file """
264
- # Create Profile object for current file
265
- d = self .data
266
-
267
- # Calculate accurate DAR
268
- pixel_ratio = openshot .Fraction (d .get ("pixel_ratio" , {}))
269
- display_ratio = openshot .Fraction (d .get ("display_ratio" , {}))
270
- if display_ratio .num == 1 and display_ratio .den == 1 :
271
- # Some audio / image files have inaccurate DAR - calculate from size
272
- display_ratio = openshot .Fraction (round (d .get ("width" , 1 ) * pixel_ratio .ToFloat ()),
273
- round (d .get ("height" , 1 ) * pixel_ratio .ToFloat ()))
274
- display_ratio .Reduce ()
275
-
276
- profile_dict = {
277
- "display_ratio" :
278
- {
279
- "den" : display_ratio .den ,
280
- "num" : display_ratio .num ,
281
- },
282
- "fps" :
283
- {
284
- "den" : d .get ("fps" , {}).get ("den" , 1 ),
285
- "num" : d .get ("fps" , {}).get ("num" , 1 ),
286
- },
287
- "height" : d .get ("height" , 1 ),
288
- "progressive" : not d .get ("interlaced_frame" , False ),
289
- "pixel_format" : d .get ("pixel_format" , None ),
290
- "pixel_ratio" :
291
- {
292
- "den" : d .get ("pixel_ratio" , {}).get ("den" , 1 ),
293
- "num" : d .get ("pixel_ratio" , {}).get ("num" , 1 ),
294
- },
295
- "width" : d .get ("width" , 1 )
296
- }
264
+ # Load file Json into Profile object
297
265
file_profile = openshot .Profile ()
298
- file_profile .SetJson (json .dumps (profile_dict ))
266
+ file_profile .SetJson (json .dumps (self . data ))
299
267
300
- # Load all possible profiles
268
+ if file_profile .info .display_ratio .num == 1 and file_profile .info .display_ratio .den == 1 :
269
+ # Some audio / image files have inaccurate DAR - calculate from size and pixel ratio
270
+ file_profile .info .display_ratio = openshot .Fraction (round (file_profile .info .width * file_profile .info .pixel_ratio .ToFloat ()), file_profile .info .height )
271
+ file_profile .info .display_ratio .Reduce ()
272
+
273
+ # Iterate through all possible profiles
301
274
for profile_folder in [info .USER_PROFILES_PATH , info .PROFILES_PATH ]:
302
275
for file in reversed (sorted (os .listdir (profile_folder ))):
303
276
profile_path = os .path .join (profile_folder , file )
@@ -306,8 +279,7 @@ def profile(self):
306
279
try :
307
280
# Load Profile
308
281
profile = openshot .Profile (profile_path )
309
- print (profile .Key (), file_profile .Key ())
310
- if profile .Key () == file_profile .Key ():
282
+ if profile == file_profile :
311
283
return profile
312
284
except RuntimeError as e :
313
285
pass
0 commit comments