From 4de39b926a580e87efd4c6c13643e32f3dc10878 Mon Sep 17 00:00:00 2001 From: j Date: Tue, 14 Nov 2023 19:52:12 +0100 Subject: [PATCH] subtitle tweaks --- management/commands/generate_clips.py | 4 +++- player/player.py | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/management/commands/generate_clips.py b/management/commands/generate_clips.py index 180a79b..e64ffcc 100644 --- a/management/commands/generate_clips.py +++ b/management/commands/generate_clips.py @@ -101,7 +101,9 @@ class Command(BaseCommand): os.symlink(src, target) subs = [] 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('
', '
').replace('
\n', '\n').replace('
', '\n') + subs.append(sdata) voice_over[fragment_id][batch] = { "src": target, "duration": source.duration, diff --git a/player/player.py b/player/player.py index cd446dc..e6dddf1 100755 --- a/player/player.py +++ b/player/player.py @@ -18,6 +18,9 @@ SYNC_GRACE_TIME = 5 SYNC_JUMP_AHEAD = 1 PORT = 9067 DEBUG = False +FONT = 'Menlo' +FONT_SIZE = 36 +FONT_BORDER = 5 def mpv_log(loglevel, component, message): @@ -44,12 +47,12 @@ class Sync(Thread): self.main = Main() if self.is_main: self.socket_enable_broadcast() - font_size = 28 - font = 'Menlo' self.mpv = mpv.MPV( 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.fullscreen = kwargs.get('fullscreen', False) @@ -231,7 +234,6 @@ def main(): while player.active: player.mpv.wait_for_playback() player.stop() - del player.mpv if __name__ == "__main__":