Closed bradenfallon closed 9 months ago
Hi @bradenfallon,
This is indeed a problem. I've found that the text in the video.add_text.ffmpeg.raw.filter
is only evaluated during filter initialization.
Do you have any preference against using the video.add_text
function?
Also savonet/liquidsoap:v2.2.2
has problems with the video.add_text.ffmpeg.raw.filter
function. So I used an ubuntu:22.04
based container.
[drawtext_0 @ 0x7fbc4645dc80] Both text and text file provided. Please provide only one
Unknown position:
Error -1: Exception raised: Avutil.Error(Invalid argument)
Raised by primitive operation at Avfilter.attach in file "avfilter/avfilter.ml", line 247, characters 4-49
Called from Builtins_ffmpeg_filters.apply_filter in file "src/core/builtins/builtins_ffmpeg_filters.ml", line 353, characters 17-68
Called from Liquidsoap_lang__Evaluation.apply.f in file "src/lang/evaluation.ml", line 174, characters 8-12
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_base_term in file "src/lang/evaluation.ml", line 272, characters 16-38
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.apply.f in file "src/lang/evaluation.ml", line 174, characters 8-12
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_base_term in file "src/lang/evaluation.ml", line 272, characters 16-38
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.apply.f in file "src/lang/evaluation.ml", line 174, characters 8-12
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Builtins_ffmpeg_filters.(fun) in file "src/core/builtins/builtins_ffmpeg_filters.ml", line 879, characters 16-58
Called from Liquidsoap_lang__Evaluation.apply.f in file "src/lang/evaluation.ml", line 174, characters 8-12
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.apply.f in file "src/lang/evaluation.ml", line 174, characters 8-12
Called from Liquidsoap_lang__Evaluation.eval_term in file "src/lang/evaluation.ml", line 341, characters 10-43
Called from Liquidsoap_lang__Evaluation.eval in file "src/lang/evaluation.ml", line 353, characters 10-38
Called from Liquidsoap_lang__Evaluation.eval_toplevel in file "src/lang/evaluation.ml", line 488, characters 38-46
Called from Liquidsoap_lang__Startup.time in file "src/lang/startup.ml", line 30, characters 12-16
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Liquidsoap_lang__Runtime.type_and_run in file "src/lang/runtime.ml", line 30, characters 4-612
Called from Liquidsoap_lang__Runtime.report in file "src/lang/runtime.ml" (inlined), line 215, characters 12-23
Called from Liquidsoap_lang__Runtime.from_lexbuf in file "src/lang/runtime.ml", line 229, characters 2-159
@vitoyucepi I'm a bit surprised by this error, we never use this parameter:
filter=
ffmpeg.filter.drawtext.create(
fontfile=font,
fontsize="#{size}",
x="#{getter.get(x)}",
y="#{getter.get(y)}",
fontcolor=color,
text=getter.get(d),
graph
)
@bradenfallon the reload mechanism is tricky with fffmpeg filters. You need to trigger the reload manually to for a reload of the filter's paramers. If you look at the filter's doc, this is explained:
Display a text. Use this operator inside ffmpeg filters with a ffmpeg video input Returns a ffmpeg video output with
on_change
andon_metadata
methods to be used to update the output text.
You can either call on_change
when the text needs to be refreshed or use on_metadat
with a specific metadata.
If you don't know when to change, you can hook up the on_change
to on_frame
as is done in our own use of use it:
s =
source.on_frame(
s,
fun () ->
begin
fn = on_frame()
fn()
end
)
s = ffmpeg.filter.video.input(graph, source.tracks(s).video)
v =
video.add_text.ffmpeg.raw.filter(
color=color,
cycle=cycle,
font=font,
metadata=metadata,
size=size,
speed=speed,
x=x,
y=y,
graph=graph,
d,
s
)
on_frame := v.on_change
Describe the bug There appears to be a bug in the video.add_text.ffmpeg.raw.filter() function, which correctly processes static text but generates incorrect output if the input is dynamic (such as changing metadata or a counter). I've included two lines of codes in one of my functions:
These output in the Liquidsoap log and show that the functions intially generating this data are running correctly. However, the issue arises after they are passed into video.add_text.ffmpeg.raw.filter().
To Reproduce
Logs
Expected behavior This code should generate a video stream that shows the currently playing song metadata, a countdown until the next song is played, and a logo overlay. Instead, the code outputs no metadata, the number 00 instead of a countdown, but the logo is displayed correctly. You can access the livestream to see the output at https://www.youtube.com/watch?v=HPhxFR1Y4MY
Version details Liquidsoap 2.2.2
Install method AzuraCast - v0.19.3 Stable - Docker - PHP 8.2