integrate zmq for drawtext, fix #40

This commit is contained in:
jb-alvarado 2019-12-14 19:37:26 +01:00
parent 2ec50f5020
commit 4515345673
2 changed files with 10 additions and 29 deletions

View File

@ -110,23 +110,13 @@ extensions = ["*.mp4"]
shuffle = False
; overlay text
; for paramters check ffmpeg doc
; leave textfile blank when you don't need this
; in some systems decimal point is a comma, have this in mind when ffmpeg complains about wrong values
; overlay text in combination with messenger: https://github.com/ffplayout/messenger
; on windows fontfile path need to be like this: C\:/WINDOWS/fonts/DejaVuSans.ttf
; textfile has the same pattern
; in a standard environment the filter drawtext node is: Parsed_drawtext_2
[TEXT]
add_text = True
textfile = /media/live.txt
fontsize = 24
fontcolor = white
bind_address = tcp://127.0.0.1:5555
fontfile = /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf
box = 1
boxcolor = black@0xbb
boxborderw = 6
x = w-w/8*mod(t,8*(w+tw)/w)
y = (h-line_h)*0.9
; the final playout post compression

View File

@ -212,15 +212,8 @@ def load_config():
_storage.shuffle = cfg.getboolean('STORAGE', 'shuffle')
_text.add_text = cfg.getboolean('TEXT', 'add_text')
_text.textfile = cfg.get('TEXT', 'textfile')
_text.fontsize = cfg.get('TEXT', 'fontsize')
_text.fontcolor = cfg.get('TEXT', 'fontcolor')
_text.address = cfg.get('TEXT', 'bind_address')
_text.fontfile = cfg.get('TEXT', 'fontfile')
_text.box = cfg.get('TEXT', 'box')
_text.boxcolor = cfg.get('TEXT', 'boxcolor')
_text.boxborderw = cfg.get('TEXT', 'boxborderw')
_text.x = cfg.get('TEXT', 'x')
_text.y = cfg.get('TEXT', 'y')
if _init.load:
_log.to_file = cfg.getboolean('LOGGING', 'log_to_file')
@ -1587,15 +1580,13 @@ def main():
'-bufsize', '{}k'.format(_pre_comp.v_bufsize)
] + pre_audio_codec() + ['-f', 'mpegts', '-']
if _text.add_text and os.path.isfile(_text.textfile):
messenger.info('Overlay text file: "{}"'.format(_text.textfile))
if _text.add_text:
messenger.info('Using drawtext node, listening on address: {}'.format(
_text.address
))
overlay = [
'-vf', ("drawtext=box={}:boxcolor='{}':boxborderw={}"
":fontsize={}:fontcolor={}:fontfile='{}':textfile={}"
":reload=1:x='{}':y='{}'").format(
_text.box, _text.boxcolor, _text.boxborderw,
_text.fontsize, _text.fontcolor, _text.fontfile,
_text.textfile, _text.x, _text.y)
'-vf', "null,zmq=b='{}',drawtext=text='':fontfile='{}'".format(
_text.address.replace(':', '\\:'), _text.fontfile)
]
try: