subtitle tweaks

This commit is contained in:
j 2023-11-14 19:52:12 +01:00
parent f00a023641
commit 4de39b926a
2 changed files with 9 additions and 5 deletions

View file

@ -101,7 +101,9 @@ class Command(BaseCommand):
os.symlink(src, target) os.symlink(src, target)
subs = [] subs = []
for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"): for sub in vo.annotations.filter(layer="subtitles").exclude(value="").order_by("start"):
subs.append(sub.json(keys=['in', 'out', 'value'])) sdata = sub.json(keys=['in', 'out', 'value'])
sdata['value'] = sdata['value'].replace('<br/>', '<br>').replace('<br>\n', '\n').replace('<br>', '\n')
subs.append(sdata)
voice_over[fragment_id][batch] = { voice_over[fragment_id][batch] = {
"src": target, "src": target,
"duration": source.duration, "duration": source.duration,

View file

@ -18,6 +18,9 @@ SYNC_GRACE_TIME = 5
SYNC_JUMP_AHEAD = 1 SYNC_JUMP_AHEAD = 1
PORT = 9067 PORT = 9067
DEBUG = False DEBUG = False
FONT = 'Menlo'
FONT_SIZE = 36
FONT_BORDER = 5
def mpv_log(loglevel, component, message): def mpv_log(loglevel, component, message):
@ -44,12 +47,12 @@ class Sync(Thread):
self.main = Main() self.main = Main()
if self.is_main: if self.is_main:
self.socket_enable_broadcast() self.socket_enable_broadcast()
font_size = 28
font = 'Menlo'
self.mpv = mpv.MPV( self.mpv = mpv.MPV(
log_handler=mpv_log, input_default_bindings=True, log_handler=mpv_log, input_default_bindings=True,
input_vo_keyboard=True, sub_text_font_size=font_size, sub_text_font=font, input_vo_keyboard=True,
sub_text_font_size=FONT_SIZE, sub_text_font=FONT,
sub_border_size=FONT_BORDER,
) )
self.mpv.observe_property('time-pos', self.time_pos_cb) self.mpv.observe_property('time-pos', self.time_pos_cb)
self.mpv.fullscreen = kwargs.get('fullscreen', False) self.mpv.fullscreen = kwargs.get('fullscreen', False)
@ -231,7 +234,6 @@ def main():
while player.active: while player.active:
player.mpv.wait_for_playback() player.mpv.wait_for_playback()
player.stop() player.stop()
del player.mpv
if __name__ == "__main__": if __name__ == "__main__":