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.4k stars 130 forks source link

LS 2.2.0+git@64732ea7a: `video.rectangle(color=0xAARRGGBB,…)` errors out #3141

Closed Moonbase59 closed 1 year ago

Moonbase59 commented 1 year ago

Describe the bug I’m trying to build a simple "lower third" and thought using using video.rectangle() would be a good option since the docs state transparency is possible with this using an alpha value in the color: color=0xAARRGGBB.

The desired outcome is roughly like this, but I wish to have the blue rectangle to be slightly transparent, so that the playing video can "shine through" a little:

Liquidsoap_001

To Reproduce Minimal script:

# half-transparent rectangle overlay ("lower third")
# color=0xAARRGGBB - AA doesn’t work
# See docs at https://www.liquidsoap.info/doc-dev/reference.html#video.rectangle

log.level := 4
s = video.testsrc(width=1280, height=720)

# This works (but is not transparent)
#s = video.rectangle(color=0x1e88e5, height=100, width=1280, x=0, y=570, s)

# This errors
s = video.rectangle(color=0x801e88e5, height=100, width=1280, x=0, y=570, s)

output.audio_video(s)

It works (but not transparent) when using a color value of 0x1e88e5, it errors out when using 0x801e88e5.

The log:

INFO: Loading Sdl_image, Target = linux
INFO: Loading Sdl_ttf, Target = linux
2023/06/12 14:03:04 >>> LOG START
2023/06/12 14:02:57 [main:3] Liquidsoap 2.2.0+git@64732ea7a
2023/06/12 14:02:57 [main:3] Using: alsa=0.3.0 angstrom=0.15.0 ao=0.2.4 asetmap=0.8.1 asn1-combinators=0.2.6 astring=0.8.5 base.caml=v0.15.1 base64=3.5.1 bigarray=[distributed with OCaml] bigarray-compat=1.1.0 bigstringaf=0.9.1 bjack=0.1.6 bos=0.2.1 bytes=[distributed with OCaml] ca-certs=v0.2.3 camlimages.all_formats=4.2.6 camlimages.core=5.0.4 camlimages.exif=5.0.4 camlimages.gif=5.0.4 camlimages.jpeg=5.0.4 camlimages.png=5.0.4 camlimages.tiff=5.0.4 camlimages.xpm=5.0.4 camlp-streams camomile=d3773ec camomile.lib=d3773ec cohttp=5.1.0 cohttp-lwt=5.1.0 cohttp-lwt-unix=5.1.0 conduit=6.2.0 conduit-lwt=6.2.0 conduit-lwt-unix=6.2.0 cry=1.0.0 cstruct=6.2.0 ctypes=0.20.2 ctypes.foreign=0.20.2 ctypes.stubs=0.20.2 curl=0.9.2 domain-name=0.4.0 dssi=0.1.5 dtools=0.4.5 dune-build-info=3.7.1 dune-private-libs.dune-section=3.7.1 dune-site=3.7.1 dune-site.private=3.7.1 duppy=0.9.3 eqaf=0.9 eqaf.bigstring=0.9 eqaf.cstruct=0.9 faad=0.5.2 fdkaac=0.3.3 ffmpeg-av=1.1.8 ffmpeg-avcodec=1.1.8 ffmpeg-avdevice=1.1.8 ffmpeg-avfilter=1.1.8 ffmpeg-avutil=1.1.8 ffmpeg-swresample=1.1.8 ffmpeg-swscale=1.1.8 fileutils=0.6.4 flac=0.4.0 flac.decoder=0.4.0 flac.ogg=0.4.0 fmt=0.9.0 fpath=0.7.3 frei0r=0.1.2 gd=1.0a5 gen=1.1 gmap=0.3.0 hkdf=1.0.4 inotify=2.4.1 integers ipaddr=5.5.0 ipaddr-sexp=5.5.0 ipaddr.unix=5.5.0 irc-client irc-client-unix ladspa=0.2.2 lame=0.3.7 lastfm=0.3.3 lilv=0.1.0 liquidsoap-lang=2.2.0 liquidsoap-lang.console=2.2.0 liquidsoap_alsa=rolling-release-v2.2.x-79-g64732ea liquidsoap_ao=rolling-release-v2.2.x-79-g64732ea liquidsoap_bjack=rolling-release-v2.2.x-79-g64732ea liquidsoap_builtins=rolling-release-v2.2.x-79-g64732ea liquidsoap_camlimages=rolling-release-v2.2.x-79-g64732ea liquidsoap_core=rolling-release-v2.2.x-79-g64732ea liquidsoap_dssi=rolling-release-v2.2.x-79-g64732ea liquidsoap_faad=rolling-release-v2.2.x-79-g64732ea liquidsoap_fdkaac=rolling-release-v2.2.x-79-g64732ea liquidsoap_ffmpeg=rolling-release-v2.2.x-79-g64732ea liquidsoap_flac=rolling-release-v2.2.x-79-g64732ea liquidsoap_frei0r=rolling-release-v2.2.x-79-g64732ea liquidsoap_gd=rolling-release-v2.2.x-79-g64732ea liquidsoap_irc=rolling-release-v2.2.x-79-g64732ea liquidsoap_ladspa=rolling-release-v2.2.x-79-g64732ea liquidsoap_lame=rolling-release-v2.2.x-79-g64732ea liquidsoap_lastfm=rolling-release-v2.2.x-79-g64732ea liquidsoap_lilv=rolling-release-v2.2.x-79-g64732ea liquidsoap_lo=rolling-release-v2.2.x-79-g64732ea liquidsoap_mad=rolling-release-v2.2.x-79-g64732ea liquidsoap_magic=rolling-release-v2.2.x-79-g64732ea liquidsoap_mem_usage=rolling-release-v2.2.x-79-g64732ea liquidsoap_memtrace=rolling-release-v2.2.x-79-g64732ea liquidsoap_ogg=rolling-release-v2.2.x-79-g64732ea liquidsoap_ogg_flac=rolling-release-v2.2.x-79-g64732ea liquidsoap_optionals=rolling-release-v2.2.x-79-g64732ea liquidsoap_opus=rolling-release-v2.2.x-79-g64732ea liquidsoap_osc=rolling-release-v2.2.x-79-g64732ea liquidsoap_oss=rolling-release-v2.2.x-79-g64732ea liquidsoap_portaudio=rolling-release-v2.2.x-79-g64732ea liquidsoap_posix_time=rolling-release-v2.2.x-79-g64732ea liquidsoap_prometheus=rolling-release-v2.2.x-79-g64732ea liquidsoap_pulseaudio=rolling-release-v2.2.x-79-g64732ea liquidsoap_runtime=rolling-release-v2.2.x-79-g64732ea liquidsoap_samplerate=rolling-release-v2.2.x-79-g64732ea liquidsoap_sdl=rolling-release-v2.2.x-79-g64732ea liquidsoap_shine=rolling-release-v2.2.x-79-g64732ea liquidsoap_soundtouch=rolling-release-v2.2.x-79-g64732ea liquidsoap_speex=rolling-release-v2.2.x-79-g64732ea liquidsoap_srt=rolling-release-v2.2.x-79-g64732ea liquidsoap_ssl=rolling-release-v2.2.x-79-g64732ea liquidsoap_stereotool=rolling-release-v2.2.x-79-g64732ea liquidsoap_taglib=rolling-release-v2.2.x-79-g64732ea liquidsoap_theora=rolling-release-v2.2.x-79-g64732ea liquidsoap_tls=rolling-release-v2.2.x-79-g64732ea liquidsoap_vorbis=rolling-release-v2.2.x-79-g64732ea liquidsoap_xmlplaylist=rolling-release-v2.2.x-79-g64732ea liquidsoap_yaml=rolling-release-v2.2.x-79-g64732ea lo=0.2.0 logs=0.7.0 logs.fmt=0.7.0 logs.lwt=0.7.0 lwt=5.6.1 lwt.unix=5.6.1 macaddr=5.5.0 mad=0.5.3 magic=0.7.3 magic-mime=1.3.0 mem_usage=0.0.4 memtrace=0.2.3 menhirLib=20230415 metadata=0.2.0 mirage-crypto=0.11.1 mirage-crypto-ec=0.11.1 mirage-crypto-pk=0.11.1 mirage-crypto-rng=0.11.1 mirage-crypto-rng.unix=0.11.1 mm=0.8.3 mm.audio=0.8.3 mm.base=0.8.3 mm.image=0.8.3 mm.midi=0.8.3 mm.video=0.8.3 ocplib-endian ocplib-endian.bigstring ogg=0.7.4 ogg.decoder=0.7.4 opus=0.2.3 opus.decoder=0.2.3 osc osc-unix parsexp=v0.15.0 pbkdf pcre=7.5.0 portaudio=0.2.3 posix-base=b516d46 posix-socket=b516d46 posix-socket.constants=b516d46 posix-socket.stubs=b516d46 posix-socket.types=b516d46 posix-time2=b516d46 posix-time2.constants=b516d46 posix-time2.stubs=b516d46 posix-time2.types=b516d46 posix-types=b516d46 posix-types.constants=b516d46 ppx_sexp_conv.runtime-lib=v0.15.0 prometheus=1.2 prometheus-app=1.2 ptime=1.1.0 ptime.clock.os=1.1.0 pulseaudio=0.1.6 re=1.10.4 result=1.5 rresult=0.7.0 samplerate=0.1.6 sedlex=3.1 seq=[distributed with OCaml 4.07 or above] sexplib=v0.15.1 sexplib0=v0.15.0 shine=0.2.3 soundtouch=0.1.9 speex=0.4.2 speex.decoder=0.4.2 srt=0.3.0 srt.constants=0.3.0 srt.stubs=0.3.0 srt.stubs.locked=0.3.0 srt.types=0.3.0 ssl=0.5.13 stdlib-shims=0.3.0 stereotool=rolling-release-v2.2.x-79-g64732ea str=[distributed with OCaml] stringext=1.6.0 taglib=0.3.10 theora=0.4.1 theora.decoder=0.4.1 threads=[distributed with OCaml] threads.posix=[distributed with OCaml] tls=0.17.0 tsdl=v1.0.0 tsdl-image=0.5 tsdl-ttf=0.5 unix=[distributed with OCaml] unix-errno=0.6.2 unix-errno.errno_bindings=0.6.2 unix-errno.errno_types=0.6.2 unix-errno.errno_types_detected=0.6.2 unix-errno.unix=0.6.2 uri=4.2.0 uri-sexp=4.2.0 uri.services=4.2.0 vorbis=0.8.1 vorbis.decoder=0.8.1 x509=0.16.4 xmlm=1.4.0 xmlplaylist=0.1.5 yaml=3.1.0 yaml.bindings=3.1.0 yaml.bindings.types=3.1.0 yaml.c=3.1.0 yaml.ffi=3.1.0 yaml.types=3.1.0 zarith=1.12
2023/06/12 14:02:57 [clock:3] Using native (high-precision) implementation for latency control
2023/06/12 14:03:04 [main:3] Standard library loaded in 7.37 seconds.
2023/06/12 14:03:04 [frame:4] frame.audio.channels set to: 2
2023/06/12 14:03:04 [frame:4] frame.audio.samplerate set to: 44100
2023/06/12 14:03:04 [frame:4] frame.video.default set to: false
2023/06/12 14:03:04 [frame:4] frame.midi.channels set to: 0
2023/06/12 14:03:04 [frame:4] frame.video.width set to: 1280
2023/06/12 14:03:04 [frame:4] frame.video.height set to: 720
2023/06/12 14:03:04 [frame:4] frame.video.framerate set to: 25
2023/06/12 14:03:04 [frame:4] frame.audio.samplerate set to: 44100
2023/06/12 14:03:04 [frame:3] Using 44100Hz audio, 25Hz video, 44100Hz main.
2023/06/12 14:03:04 [frame:3] Video frame size set to: 1280x720
2023/06/12 14:03:04 [frame:3] Frame size must be a multiple of 1764 ticks = 1764 audio samples = 1 video samples.
2023/06/12 14:03:04 [frame:3] Targeting 'frame.duration': 0.04s = 1764 audio samples = 1764 ticks.
2023/06/12 14:03:04 [frame:3] Frames last 0.04s = 1764 audio samples = 1 video samples = 1764 ticks.
2023/06/12 14:03:04 [sandbox:3] Sandboxing disabled
2023/06/12 14:03:04 [startup:3] DSSI plugins registration: 0.00s
2023/06/12 14:03:04 [startup:3] FFmpeg filters registration: 0.08s
2023/06/12 14:03:04 [startup:3] FFmpeg bitstream filters registration: 0.00s
2023/06/12 14:03:04 [startup:3] Lilv plugins registration: 0.02s
2023/06/12 14:03:04 [startup:3] Frei0r plugin registration: 0.00s
2023/06/12 14:03:04 [startup:3] LADSPA plugins registration: 0.00s
2023/06/12 14:03:04 [startup:3] Typechecking: 7.14s
2023/06/12 14:03:04 [startup:3] Evaluation: 0.03s
2023/06/12 14:03:04 [startup:3] Typechecking: 0.05s
2023/06/12 14:03:04 [startup:3] Evaluation: 0.00s
2023/06/12 14:03:04 [startup:3] Typechecking: 0.00s
2023/06/12 14:03:04 [startup:3] Evaluation: 0.12s
2023/06/12 14:03:04 [startup:3] Loaded test4.liq: 0.12s
2023/06/12 14:03:04 [video.converter:3] Using preferred video converter: ffmpeg.
2023/06/12 14:03:04 [audio.converter:3] Using samplerate converter: libsamplerate.
2023/06/12 14:03:04 [clock:4] Currently 1 clock(s) allocated.
2023/06/12 14:03:04 [clock.pulseaudio:4] Starting 2 source(s)...
2023/06/12 14:03:04 [source:4] Source output.pulseaudio gets up with content type: {audio=pcm(stereo)}.
2023/06/12 14:03:04 [pulse_out(liquidsoap:):3] Content type is {audio=pcm(stereo)}.
2023/06/12 14:03:04 [source:4] Source source gets up with content type: {audio=pcm(stereo)}.
2023/06/12 14:03:04 [source:3] Content type is {audio=pcm(stereo)}.
2023/06/12 14:03:04 [source:4] Source video.rectangle gets up with content type: {audio=pcm(stereo),video=canvas}.
2023/06/12 14:03:04 [video.rectangle:3] Content type is {audio=pcm(stereo),video=canvas}.
2023/06/12 14:03:04 [source:4] Source video.testsrc gets up with content type: {audio=pcm(stereo),video=canvas}.
2023/06/12 14:03:04 [video.testsrc:3] Content type is {audio=pcm(stereo),video=canvas}.
2023/06/12 14:03:04 [source:4] Source output.sdl gets up with content type: {video=canvas}.
2023/06/12 14:03:04 [sdl:3] Content type is {video=canvas}.
2023/06/12 14:03:04 [source:4] Source source.2 gets up with content type: {video=canvas}.
2023/06/12 14:03:04 [source.2:3] Content type is {video=canvas}.
2023/06/12 14:03:04 [sdl:4] Initialized SDL video surface.
2023/06/12 14:03:04 [threads:4] Created thread "clock_pulseaudio" (1 total).
2023/06/12 14:03:04 [clock:4] Main phase starts.
2023/06/12 14:03:04 [threads:4] Created thread "generic queue #1" (1 total).
2023/06/12 14:03:04 [threads:4] Created thread "generic queue #2" (2 total).
2023/06/12 14:03:04 [threads:4] Created thread "non-blocking queue #1" (3 total).
2023/06/12 14:03:04 [threads:4] Created thread "non-blocking queue #2" (4 total).
2023/06/12 14:03:04 [video.text:3] Using sdl implementation
2023/06/12 14:03:04 [clock.pulseaudio:3] Streaming loop starts in auto-sync mode
2023/06/12 14:03:04 [clock.pulseaudio:3] Delegating synchronization to CPU clock
2023/06/12 14:03:04 [clock.pulseaudio:2] Source pulse_out(liquidsoap:) failed while streaming: Invalid_argument("Not a color")!
2023/06/12 14:03:04 [clock.pulseaudio:2] Raised at Mm_image__ImageBase.RGB8.Color.of_int in file "src/imageBase.ml", line 171, characters 27-65
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Video_effects.(fun) in file "src/core/operators/video_effects.ml", line 209, characters 12-47
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Mm_video__Video.MakeCanvas.map in file "src/video.ml", line 135, characters 17-26
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Video_effects.base#get_frame in file "src/core/operators/video_effects.ml", line 39, characters 16-60
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#instrumented_get_frame in file "src/core/source.ml", line 642, characters 6-24
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#get in file "src/core/source.ml", line 766, characters 12-44
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Muxer.muxer#feed_fields in file "src/core/operators/muxer.ml", line 93, characters 8-22
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Muxer.muxer#feed in file "src/core/operators/muxer.ml", line 110, characters 8-51
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Muxer.muxer#get_frame in file "src/core/operators/muxer.ml", line 132, characters 6-31
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#instrumented_get_frame in file "src/core/source.ml", line 642, characters 6-24
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#get in file "src/core/source.ml", line 749, characters 10-41
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Output.output#output in file "src/core/outputs/output.ml", line 165, characters 10-30
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Clock.MkClock.clock#end_tick.(fun) in file "src/core/clock.ml", line 313, characters 16-24
2023/06/12 14:03:04 [clock.pulseaudio:2] 
2023/06/12 14:03:04 [source:4] Source pulse_out(liquidsoap:) gets down.
2023/06/12 14:03:04 [source:4] Source source gets down.
2023/06/12 14:03:04 [clock.pulseaudio:2] Source sdl failed while streaming: Invalid_argument("Not a color")!
2023/06/12 14:03:04 [clock.pulseaudio:2] Raised at Mm_image__ImageBase.RGB8.Color.of_int in file "src/imageBase.ml", line 171, characters 27-65
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Video_effects.(fun) in file "src/core/operators/video_effects.ml", line 209, characters 12-47
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Mm_video__Video.MakeCanvas.map in file "src/video.ml", line 135, characters 17-26
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Video_effects.base#get_frame in file "src/core/operators/video_effects.ml", line 39, characters 16-60
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#instrumented_get_frame in file "src/core/source.ml", line 642, characters 6-24
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#get in file "src/core/source.ml", line 749, characters 10-41
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Muxer.muxer#feed_fields in file "src/core/operators/muxer.ml", line 93, characters 8-22
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Stdlib__List.iter in file "list.ml", line 110, characters 12-15
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Muxer.muxer#feed in file "src/core/operators/muxer.ml", line 110, characters 8-51
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Muxer.muxer#get_frame in file "src/core/operators/muxer.ml", line 132, characters 6-31
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#instrumented_get_frame in file "src/core/source.ml", line 642, characters 6-24
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Source.operator#get in file "src/core/source.ml", line 749, characters 10-41
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Output.output#output in file "src/core/outputs/output.ml", line 165, characters 10-30
2023/06/12 14:03:04 [clock.pulseaudio:2] Called from Clock.MkClock.clock#end_tick.(fun) in file "src/core/clock.ml", line 313, characters 16-24
2023/06/12 14:03:04 [clock.pulseaudio:2] 
2023/06/12 14:03:04 [source:4] Source sdl gets down.
2023/06/12 14:03:04 [source:4] Source source.2 gets down.
2023/06/12 14:03:04 [source:4] Source video.rectangle gets down.
2023/06/12 14:03:04 [source:4] Source video.testsrc gets down.
2023/06/12 14:03:04 [clock.pulseaudio:3] Streaming loop stopped.
2023/06/12 14:03:04 [main:3] Shutdown started!
2023/06/12 14:03:04 [main:3] Waiting for main threads to terminate...
2023/06/12 14:03:04 [threads:4] Thread "clock_pulseaudio" terminated (0 remaining).
2023/06/12 14:03:04 [main:3] Main threads terminated.
2023/06/12 14:03:04 [threads:3] Shutting down scheduler...
2023/06/12 14:03:04 [threads:4] Thread "generic queue #1" terminated (3 remaining).
2023/06/12 14:03:04 [threads:4] Thread "non-blocking queue #2" terminated (2 remaining).
2023/06/12 14:03:04 [threads:4] Thread "generic queue #2" terminated (1 remaining).
2023/06/12 14:03:04 [threads:4] Thread "non-blocking queue #1" terminated (0 remaining).
2023/06/12 14:03:04 [threads:3] Scheduler shut down.
2023/06/12 14:03:04 [main:3] Cleaning downloaded files...
2023/06/12 14:03:04 [main:3] Freeing memory...
2023/06/12 14:03:05 >>> LOG END

Expected behavior No error, and the alpha value 0x80 respected.

Version details

Install method .deb from release-assets

Moonbase59 commented 1 year ago

Fantastic! Confirm fixed in a26bf05 (I used the .deb from the release assets). Thanks a bundle.