@@ -70,18 +70,23 @@ def fraction(inp, fps) -> str:
70
70
if (isinstance (fps , float )):
71
71
fps = Fraction (fps )
72
72
73
-
74
73
frac = Fraction (inp , fps ).limit_denominator ()
75
74
num = frac .numerator
76
75
dem = frac .denominator
77
76
78
77
if (dem < 3000 ):
79
78
factor = int (3000 / dem )
80
- print (3000 / dem )
81
- print (f'{ num } /{ dem } ' )
82
- num *= factor
83
- dem *= factor
84
- print (f'{ num } /{ dem } ' )
79
+
80
+ if (factor == 3000 / dem ):
81
+ num *= factor
82
+ dem *= factor
83
+ else :
84
+ # Good enough but has some error that are impacted at speeds such as 150%.
85
+ total = 0
86
+ while (total < frac ):
87
+ total += Fraction (1 , 30 )
88
+ num = total .numerator
89
+ dem = total .denominator
85
90
86
91
return f'{ num } /{ dem } s'
87
92
@@ -99,7 +104,6 @@ def fraction(inp, fps) -> str:
99
104
with open (output , 'w' , encoding = 'utf-8' ) as outfile :
100
105
101
106
frame_duration = fraction (1 , fps )
102
- new_duration = fraction (chunks [len (chunks ) - 1 ][1 ], fps )
103
107
104
108
outfile .write ('<?xml version="1.0" encoding="UTF-8"?>\n ' )
105
109
outfile .write ('<!DOCTYPE fcpxml>\n \n ' )
@@ -121,7 +125,7 @@ def fraction(inp, fps) -> str:
121
125
outfile .write ('\t \t <event name="auto-editor output">\n ' )
122
126
outfile .write (f'\t \t \t <project name="{ name } ">\n ' )
123
127
outfile .write (formatXML (4 ,
124
- f'<sequence duration=" { new_duration } " format="r1" tcStart="0s" tcFormat="NDF" ' \
128
+ f'<sequence format="r1" tcStart="0s" tcFormat="NDF" ' \
125
129
'audioLayout="stereo" audioRate="48k">' ,
126
130
'\t <spine>' )
127
131
)
@@ -138,7 +142,7 @@ def fraction(inp, fps) -> str:
138
142
outfile .write (formatXML (6 , f'<asset-clip name="{ name } " offset="0s" ref="r2"' \
139
143
f' duration="{ dur } " audioRole="dialogue" tcFormat="NDF"{ close } >' ))
140
144
else :
141
- start = fraction (clip [0 ], fps )
145
+ start = fraction (clip [0 ] / ( clip [ 2 ] / 100 ) , fps )
142
146
off = fraction (last_dur , fps )
143
147
outfile .write (formatXML (6 ,
144
148
f'<asset-clip name="{ name } " offset="{ off } " ref="r2"' \
@@ -151,7 +155,6 @@ def fraction(inp, fps) -> str:
151
155
frac_total = fraction (total_dur , fps )
152
156
total_dur_divided_by_speed = fraction ((total_dur ) / (clip [2 ] / 100 ), fps )
153
157
154
-
155
158
outfile .write (formatXML (6 ,
156
159
'\t <timeMap>' ,
157
160
'\t \t <timept time="0s" value="0s" interp="smooth2"/>' ,
0 commit comments