From 6876f2cf44e302f272fc15bdc45743d23c30955a Mon Sep 17 00:00:00 2001 From: Jannik Beyerstedt Date: Sat, 2 Nov 2024 14:23:34 +0100 Subject: [PATCH] make-ffmpeg: Rework config file --- camp2023/config.ini | 8 ++---- cccamp19/config.ini | 8 ++---- denog11/config.ini | 8 ++---- jh19-berlin/config.ini | 8 ++---- jh20-jue/config.ini | 7 +----- jh21-rn/config.ini | 8 ++---- jugendhackt/config.ini | 39 ++++++++++++++++++++---------- make-ffmpeg.py | 55 +++++++++++++++++++++++++----------------- mrmcd2019/config.ini | 8 ++---- vcfb24/config.ini | 2 +- 10 files changed, 73 insertions(+), 78 deletions(-) diff --git a/camp2023/config.ini b/camp2023/config.ini index 2072250..5dbefd6 100644 --- a/camp2023/config.ini +++ b/camp2023/config.ini @@ -1,15 +1,13 @@ -[default] +[meta] schedule = https://pretalx.c3voc.de/camp2023/schedule/export/schedule.xml template = intro.mp4 alpha = false prores = false -fontfile = true -inout = t +inout_type = t [title] in = 16 out = 24 -fontfamily = BeonRegular fontfile = saira.ttf fontsize = 100 fontcolor = #FB48C4 @@ -19,7 +17,6 @@ y = 100 [speaker] in = 16 out = 24 -fontfamily = BeonRegular fontfile = saira.ttf fontsize = 70 fontcolor = #3FFF21 @@ -29,7 +26,6 @@ y = 800 [text] in = 16 out = 24 -fontfamily = BeonRegular fontfile = saira.ttf fontsize = 45 fontcolor = #FB48C4 diff --git a/cccamp19/config.ini b/cccamp19/config.ini index 181caed..0316909 100644 --- a/cccamp19/config.ini +++ b/cccamp19/config.ini @@ -1,15 +1,13 @@ -[default] +[meta] schedule = https://fahrplan.events.ccc.de/camp/2019/Fahrplan/schedule.xml template = cccamp19_talks_intro_1080p.mov alpha = true prores = true -fontfile = true -inout = n +inout_type = n [title] in = 193 out = 324 -fontfamily = fontfile = Marvel-Bold.ttf fontsize = 120 fontcolor = #c68100 @@ -19,7 +17,6 @@ y = 480 [speaker] in = 233 out = 324 -fontfamily = fontfile = Marvel-Regular.ttf fontsize = 70 fontcolor = #c68100 @@ -29,7 +26,6 @@ y = 845 [text] in = 242 out = 324 -fontfamily = fontfile = Marvel-Regular.ttf fontsize = 45 fontcolor = #c68100 diff --git a/denog11/config.ini b/denog11/config.ini index 6f403b5..0716e7e 100644 --- a/denog11/config.ini +++ b/denog11/config.ini @@ -1,15 +1,13 @@ -[default] +[meta] schedule = https://pretalx.denog.de/denog11/schedule/export/schedule.xml template = denog11_intro_template.ts alpha = false prores = false -fontfile = true -inout = n +inout_type = n [title] in = 1 out = 6.5 -fontfamily = fontfile = DejaVuSans.ttf fontsize = 100 fontcolor = #f9cc12 @@ -19,7 +17,6 @@ y = 200 [speaker] in = 2 out = 6.5 -fontfamily = fontfile = DejaVuSans.ttf fontsize = 60 fontcolor = #ffffff @@ -29,7 +26,6 @@ y = 900 [text] in = 3 out = 6.5 -fontfamily = fontfile = DejaVuSans.ttf fontsize = 45 fontcolor = #ffffff diff --git a/jh19-berlin/config.ini b/jh19-berlin/config.ini index 6a8740d..171ea67 100644 --- a/jh19-berlin/config.ini +++ b/jh19-berlin/config.ini @@ -1,15 +1,13 @@ -[default] +[meta] schedule = https://projects.alpaka.space/media/jhber19-schedule.xml template = intro-alpha.mov alpha = true prores = true -fontfile = true -inout = n +inout_type = n [title] in = 175 out = 260 -fontfamily = fontfile = SourceSansPro-Bold.otf fontsize = 90 fontcolor = #ffffff @@ -19,7 +17,6 @@ y = 450 [speaker] in = 175 out = 260 -fontfamily = fontfile = SourceSansPro-Regular.otf fontsize = 36 fontcolor = #ffffff @@ -29,7 +26,6 @@ y = 900 [text] in = 200 out = 250 -fontfamily = fontfile = SourceSansPro-Regular.otf fontsize = 45 fontcolor = #c68100 diff --git a/jh20-jue/config.ini b/jh20-jue/config.ini index 163ca71..7f65b89 100644 --- a/jh20-jue/config.ini +++ b/jh20-jue/config.ini @@ -1,12 +1,10 @@ -[default] +[meta] schedule = https://releasing.c3voc.de/releases/jhjue2020/schedule-jhjue20.xml ; intro_template.ts was derived from a png which was derived from jhjue-20-intro.svg ; ffmpeg -loop 1 -i jh20-jue/jh20-jue-intro.png -ar 48000 -ac 2 -f s16le -i /dev/zero -c:v mpeg2video -pix_fmt:v yuv420p -qscale:v 2 -qmin:v 2 -qmax:v 7 -keyint_min 0 -bf 0 -g 0 -intra:0 -maxrate:0 90M -c:a mp2 -b:a 384k -t 5 jh20-jue/jh20-jue_intro_template.ts template = jh20-jue_intro_template.ts alpha = false prores = false -; enable using a font file -fontfile = true ; in and out time format: t for seconds, n for frame number inout = n @@ -17,7 +15,6 @@ in = 20 ; outframe for totle out = 225 ; title font (either font family or file, see default setting above) -fontfamily = fontfile = ebisu.ttf ; title font size fontsize = 70 @@ -30,7 +27,6 @@ y = 865 [speaker] in = 40 out = 225 -fontfamily = fontfile = ebisu.ttf fontsize = 40 fontcolor = #eeeeee @@ -41,7 +37,6 @@ y = 950 [text] in = 3 out = 4 -fontfamily = fontfile = ebisu.ttf fontsize = 45 fontcolor = #ffffff diff --git a/jh21-rn/config.ini b/jh21-rn/config.ini index a7870db..8c25d4d 100644 --- a/jh21-rn/config.ini +++ b/jh21-rn/config.ini @@ -1,15 +1,13 @@ -[default] +[meta] schedule = https://pretalx.c3voc.de/jugend-hackt-rhein-neckar-2021/schedule/export/schedule.xml template = jh21-rn-template.ts alpha = false prores = false -fontfile = true -inout = t +inout_type = t [title] in = 1 out = 6.5 -fontfamily = fontfile = SourceSansPro-Semibold.ttf fontsize = 85 fontcolor = #ffffff @@ -19,7 +17,6 @@ y = 877 [speaker] in = 2 out = 6.5 -fontfamily = fontfile = SourceSansPro-Semibold.ttf fontsize = 45 fontcolor = #ffffff @@ -29,7 +26,6 @@ y = 954 [text] in = 3 out = 6.5 -fontfamily = fontfile = SourceSansPro-Semibold.ttf fontsize = 45 fontcolor = #ffffff diff --git a/jugendhackt/config.ini b/jugendhackt/config.ini index 2400940..da1b7bd 100644 --- a/jugendhackt/config.ini +++ b/jugendhackt/config.ini @@ -1,39 +1,52 @@ -[default] +[meta] schedule = https://pretalx.c3voc.de/jhhh23/schedule/export/schedule.xml +;; path to background video template = intro-background.ts +;; whether background video uses transparency (needs to be .mov) alpha = false +;; whether background video is prores 4444 prores = false -fontfile = true -inout = t +;; in and out time format: t for seconds, n for frame number +inout_type = t +;; Some font settings can have defaults, which can be overridden in the +;; 'title', 'speaker' and 'text' sections below. +[default] +;; default font (either use 'fontfamily' or 'fontfile') +; fontfamily = arial +fontfile = SourceSansPro-Semibold.ttf +;; default font color +fontcolor = #ffffff + +;; fields for title and speaker names are empty in the template.ts, so we'll render them in via ffmpeg +;; parameters are: +;; - in: start frame/ time +;; - out: end frame/ time +;; - fontfamily: font family +;; - fontfile: font file +;; - fontcolor: font color +;; - fontsize: font size (pixel) +;; - x: horizontal position (top left corner) +;; - y: vertical position (top left corner) [title] in = 1 out = 9.5 -fontfamily = -fontfile = SourceSansPro-Semibold.ttf fontsize = 67 -fontcolor = #ffffff x = 400 y = 870 [speaker] in = 2 out = 9 -fontfamily = -fontfile = SourceSansPro-Semibold.ttf fontsize = 50 -fontcolor = #ffffff x = 400 y = 950 - +;; optional extra text [text] in = 0 out = 0 -fontfamily = -fontfile = SourceSansPro-Semibold.ttf fontsize = 0 -fontcolor = #ffffff x = 0 y = 0 text = '' diff --git a/make-ffmpeg.py b/make-ffmpeg.py index 0fbc353..3b69978 100755 --- a/make-ffmpeg.py +++ b/make-ffmpeg.py @@ -1,6 +1,8 @@ #!/usr/bin/env python3 # vim: tabstop=4 shiftwidth=4 expandtab +"""See jugendhackt/config.ini for some config file documentation.""" + import os import sys import subprocess @@ -21,33 +23,39 @@ class TextConfig: x: int y: int - use_fontfile: bool - fontfile: str fontfile_path: str fontfamily: str fontsize: int - fontcolor: str = "#ffffff" + fontcolor: str bordercolor: str = None # border is added, if a color is set - def parse(self, cparser_sect, use_fontfile: bool): + def uses_fontfile(self): + return self.fontfile_path is not None + + def parse(self, cparser_sect, default_fontfile, default_fontfamily, default_fontcolor): self.inpoint = cparser_sect.getfloat('in') self.outpoint = cparser_sect.getfloat('out') self.x = cparser_sect.getint('x') self.y = cparser_sect.getint('y') - self.use_fontfile = use_fontfile - if use_fontfile: - self.fontfile = cparser_sect.get('fontfile') - self.fontfile_path = str(PurePath(args.project, self.fontfile).as_posix()) + self.fontcolor = cparser_sect.get('fontcolor', default_fontcolor) + + fontfile = cparser_sect.get('fontfile', default_fontfile) + fontfamily = cparser_sect.get('fontfamily', default_fontfamily) + if fontfile != None and fontfamily is None: + self.fontfile_path = str(PurePath(args.project, fontfile).as_posix()) if not os.path.exists(self.fontfile_path): error("Font file {} in Project Path is missing".format(self.fontfile_path)) + + elif fontfamily != None and fontfile is None: + self.fontfamily = fontfamily + else: - self.fontfamily = cparser_sect.get('fontfamily') + error("Either provide a 'fontfamily' or 'fontfile', not both") self.fontsize = cparser_sect.getint('fontsize') - self.fontcolor = cparser_sect.get('fontcolor', self.fontcolor) self.bordercolor = cparser_sect.get('bordercolor', None) def fit_text(self, text: str): @@ -63,7 +71,7 @@ class TextConfig: filter_str = "drawtext=enable='between({},{},{})'".format( inout_type, self.inpoint, self.outpoint) - if self.use_fontfile: + if self.uses_fontfile(): filter_str += ":fontfile='{}'".format(self.fontfile_path) else: filter_str += ":font='{}'".format(self.fontfamily) @@ -82,7 +90,6 @@ class Config: template_file: str # video background alpha: bool = False prores: bool = False - use_fontfile: bool = False inout_type: str = "t" # in and out time format: t for seconds, n for frame number fileext: str @@ -102,21 +109,25 @@ def parse_config(filename) -> Config: cparser = ConfigParser() cparser.read(filename) - defaults = cparser['default'] - conf.schedule = defaults.get('schedule') - infile = PurePath(args.project, defaults.get('template')) + meta = cparser['meta'] + conf.schedule = meta.get('schedule') + infile = PurePath(args.project, meta.get('template')) conf.template_file = str(infile) - conf.alpha = defaults.getboolean('alpha', conf.alpha) - conf.prores = defaults.getboolean('prores', conf.prores) - conf.use_fontfile = defaults.get('fontfile', conf.use_fontfile) - conf.inout_type = defaults.get('inout', conf.inout_type) + conf.alpha = meta.getboolean('alpha', conf.alpha) + conf.prores = meta.getboolean('prores', conf.prores) + conf.inout_type = meta.get('inout_type', conf.inout_type) + + defaults = cparser['default'] + default_fontfile = defaults.get('fontfile', None) + default_fontfamily = defaults.get('fontfamily', None) + default_fontcolor = defaults.get('fontcolor', "#ffffff") conf.title = TextConfig() - conf.title.parse(cparser['title'], conf.use_fontfile) + conf.title.parse(cparser['title'], default_fontfile, default_fontfamily, default_fontcolor) conf.speaker = TextConfig() - conf.speaker.parse(cparser['speaker'], conf.use_fontfile) + conf.speaker.parse(cparser['speaker'], default_fontfile, default_fontfamily, default_fontcolor) conf.text = TextConfig() - conf.text.parse(cparser['text'], conf.use_fontfile) + conf.text.parse(cparser['text'], default_fontfile, default_fontfamily, default_fontcolor) conf.text_text = cparser['text'].get('text', '') diff --git a/mrmcd2019/config.ini b/mrmcd2019/config.ini index 165753c..30da816 100755 --- a/mrmcd2019/config.ini +++ b/mrmcd2019/config.ini @@ -1,16 +1,14 @@ -[default] +[meta] #schedule = https://talks.mrmcd.net/2019/schedule/export/schedule.xml schedule = file:///home/thorti/git/c3voc/intro-outro-generator/mrmcd2019/schedule.xml template = mrmcd2019.mov alpha = false prores = false -fontfile = true -inout = n +inout_type = n [title] in = 50 out = 225 -fontfamily = fontfile = Jura-Bold.ttf fontsize = 80 fontcolor = #47acda @@ -20,7 +18,6 @@ y = 540 [speaker] in = 75 out = 225 -fontfamily = fontfile = Jura-Regular.ttf fontsize = 50 fontcolor = #094762 @@ -30,7 +27,6 @@ y = 950 [text] in = 242 out = 324 -fontfamily = fontfile = Jura-Regular.ttf fontsize = 45 fontcolor = #c68100 diff --git a/vcfb24/config.ini b/vcfb24/config.ini index 0fb3ad3..fff89ad 100644 --- a/vcfb24/config.ini +++ b/vcfb24/config.ini @@ -1,4 +1,4 @@ -[default] +[meta] schedule = http://vcfb.de/2024/schedule.xml # ffmpeg -loop 1 -i intro.png -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -c:v libx264 -tune stillimage -pix_fmt yuv420p -c:a aac -r 25 -t 10 intro.mp4 template = intro.mp4