You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
def frame_to_duration(frame, exts, end = False):
duration = 0
frame_count = frame + 1 if end else frame
for i in range(frame_count):
duration += exts[i]['delay_time'] if exts[i]['delay_time'] > 0 else 1
return duration
import gzip
import json
FPS = 60
MAX_DURATION = FPS * 3
def frame_to_duration(frame, exts, end = False):
duration = 0
frame_count = frame + 1 if end else frame
for i in range(frame_count):
duration += exts[i]['delay_time'] if exts[i]['delay_time'] > 0 else 1
return duration
def gif_duration_to_fr(duration, scale_factor):
return duration / 100.0 * FPS / scale_factor
def save(frames, name, exts):
duration = 0
for ext in exts:
duration += ext['delay_time'] if ext['delay_time'] > 0 else 1
scale_factor = 1.0 if duration < MAX_DURATION else duration / MAX_DURATION
def shape_to_tgs(shape):
tgs_shape = {
'ty': 'gr',
'nm': '',
'bm': 0,
}
def frame_seq_to_layer(frame_seq, exts, scale_factor):
ref_shape = frame_seq[0]
layer = {
'ty': 4,
'ks': {
'o': {
'a': 0,
'k': 100,
},
'r': {
'a': 0,
'k': 0,
},
'p': {
'a': 0,
'k': [0, 0, 0],
},
'a': {
'a': 0,
'k': [0, 0, 0],
},
's': {
'a': 0,
'k': [100, 100, 100],
},
},
'ao': 0,
'ddd': 0,
'ip': round(gif_duration_to_fr(frame_to_duration(ref_shape['startFrame'], exts), scale_factor)),
'op': round(gif_duration_to_fr(frame_to_duration(ref_shape['endFrame'], exts, end = True), scale_factor)) + 1,
'sr': 1,
'nm': '',
}
layer['st'] = layer['ip']
layer['shapes'] = [shape_to_tgs(shape) for shape in frame_seq]
The text was updated successfully, but these errors were encountered: