savonet / liquidsoap

Liquidsoap is a statically typed scripting general-purpose language with dedicated operators and backend for all thing media, streaming, file generation, automation, HTTP backend and more.
http://liquidsoap.info
GNU General Public License v2.0
1.41k stars 130 forks source link

LS 2.2.0 1f26595: Adding videos example from Book p. 211 doesn’t work #3197

Open Moonbase59 opened 1 year ago

Moonbase59 commented 1 year ago

Describe the bug The example "Adding videos" from the Liquidsoap Book p. 211 doesn’t work.

I try to add a logo to a video like shown in the book:

# Example from Liquidsoap Book p. 211: Adding videos.

v = video.testsrc(width=1280, height=720)
logo = image("annotate:x=50,y=50,width=100,height=100:niteradio-cover.png")
v = add([v, logo])

output.audio_video(v)

but Liquidsoap shows one of the dreaded type errors:

INFO: Loading Sdl_image, Target = linux
INFO: Loading Sdl_ttf, Target = linux
At test3.liq, line 7, char 19:
output.audio_video(v)

Error 5: this value has type
  source(audio=_, ?video=canvas('A)) (inferred at source.liq, line 6 char 2 - line 39 char 5)
but it should be a subtype of the type of the value at io.liq, line 72, char 90
  source(audio=_, video=canvas('A))

To Reproduce See above.

Expected behavior Examples working. Hee hee. ;-) I know documentation always lags behind but it’s real hard for a newbie trying to learn if examples don’t work.

Maybe just show how it should be done now, please? (I’m using image because it has a set method, so I can exchange the image later, so video.add_image in its current state won’t help here.)

Version details

Install method .deb from release-assets

smimram commented 1 year ago

Should be fixed by #3233.

Moonbase59 commented 1 year ago

@smimram Not completely: Doesn’t throw an error with LS 2.2.0+git@661820a5a, but doesn’t respect x= and y= annotations:

v = image("Nite Radio Testbild.png")
a = sine(amplitude=lin_of_dB(-23.0), 1000.0)
logo = image("annotate:x=50,y=50,width=100,height=100:niteradio-cover.png")
v = mux_video(video=v, a)
v = add([v, logo])

output.audio_video(v)

Output (logo is in upper left corner instead at 50,50):

Liquidsoap_003

smimram commented 1 year ago

The image operator now has arguments x, y etc. so that you can write

v = image("Nite Radio Testbild.png")
a = sine(amplitude=lin_of_dB(-23.0), 1000.0)
logo = image(x=50,y=50,width=100,height=100,"niteradio-cover.png")
v = mux_video(video=v, a)
v = add([v, logo])

output.audio_video(v)

(untested)

Moonbase59 commented 1 year ago

Yep, I know, but there are cases where it makes sense to build annotations in preprocessing, and it feels inconsistent that size works but position does not. :-)