Compare commits
2 commits
bfb1c7da40
...
eff0576af3
| Author | SHA1 | Date | |
|---|---|---|---|
| eff0576af3 | |||
| ea91ec7659 |
2 changed files with 25 additions and 13 deletions
12
render.py
12
render.py
|
|
@ -157,11 +157,9 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
|||
}
|
||||
})
|
||||
|
||||
volume_front = '-2.5'
|
||||
volume_rear = '-8.5'
|
||||
volume_front = '-17'
|
||||
if clip.get('volume') is not None:
|
||||
volume_front = '%0.2f' % (float(volume_front) + clip['volume'])
|
||||
volume_rear = '%0.2f' % (float(volume_rear) + clip['volume'])
|
||||
|
||||
'''
|
||||
'dynamic_loudness': [
|
||||
|
|
@ -187,14 +185,6 @@ def compose(clips, fragment, target=150, base=1024, voice_over=None, options=Non
|
|||
'src': audio,
|
||||
'filter': audio_filter.copy()
|
||||
})
|
||||
'''
|
||||
audio_filter['volume'] = volume_rear
|
||||
scene['audio-rear']['A2'].append({
|
||||
'duration': clip['duration'],
|
||||
'src': audio,
|
||||
'filter': audio_filter.copy()
|
||||
})
|
||||
'''
|
||||
used.append(clip)
|
||||
if not clips and target - length > 0:
|
||||
print("not enough clips, need to reset")
|
||||
|
|
|
|||
|
|
@ -116,6 +116,28 @@ def shift_clips(data, offset):
|
|||
return data
|
||||
|
||||
|
||||
def ass_timestamp(seconds):
|
||||
hours = int(seconds // 3600)
|
||||
minutes = int((seconds % 3600) // 60)
|
||||
secs = seconds % 60
|
||||
|
||||
whole_seconds = int(secs)
|
||||
centiseconds = int(round((secs - whole_seconds) * 100))
|
||||
|
||||
# Handle centisecond rollover (e.g., 59.999 → 60.00)
|
||||
if centiseconds == 100:
|
||||
whole_seconds += 1
|
||||
centiseconds = 0
|
||||
if whole_seconds == 60:
|
||||
whole_seconds = 0
|
||||
minutes += 1
|
||||
if minutes == 60:
|
||||
minutes = 0
|
||||
hours += 1
|
||||
|
||||
return f"{hours}:{minutes:02d}:{whole_seconds:02d}.{centiseconds:02d}"
|
||||
|
||||
|
||||
def ass_encode(subs, options):
|
||||
if "lang" in options:
|
||||
langs = options["lang"].split(",")
|
||||
|
|
@ -158,8 +180,8 @@ Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour,
|
|||
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text"
|
||||
]
|
||||
for sub in subs:
|
||||
start = ox.format_timecode(sub["in"]).rstrip("0")
|
||||
stop = ox.format_timecode(sub["out"]).rstrip("0")
|
||||
start = ass_timestamp(sub["in"])
|
||||
stop = ass_timestamp(sub["out"])
|
||||
for lang in reversed(langs):
|
||||
value = sub["values"][lang]
|
||||
event = f"Dialogue: 0,{start},{stop},{lang},,0,0,0,,{value}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue