Add generic streaming interpreter with configurable sources/audio

- Add stream_sexp_generic.py: fully generic sexp interpreter
- Add streaming primitives for video sources and audio analysis
- Add config system for external sources and audio files
- Add templates for reusable scans and macros
- Fix video/audio stream mapping in file output
- Add dynamic source cycling based on sources array length
- Remove old Python effect files (migrated to sexp)
- Update sexp effects to use namespaced primitives

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
gilesb
2026-02-02 17:48:04 +00:00
parent d241e2a663
commit 95fcc67dcc
179 changed files with 3935 additions and 8226 deletions

View File

@@ -1,56 +1,31 @@
;; Blend effect - combines two video streams
;; Multi-input effect: uses frame-a and frame-b
;; Blend effect - combines two video frames
;; Streaming-compatible: frame is background, overlay is second frame
;; Usage: (blend background overlay :opacity 0.5 :mode "alpha")
;;
;; Params:
;; mode - blend mode (add, multiply, screen, overlay, difference, lighten, darken, alpha)
;; opacity - blend amount (0-1)
;; resize_mode - how to resize frame-b to match frame-a (fit, crop, stretch)
;; priority - which dimension takes priority (width, height)
;; pad_color - color for padding in fit mode [r g b]
(require-primitives "image" "blending")
(require-primitives "image" "blending" "core")
(define-effect blend
:params (
(mode :type string :default "overlay")
(overlay :type frame :default nil)
(mode :type string :default "alpha")
(opacity :type float :default 0.5)
(resize_mode :type string :default "fit")
(priority :type string :default "width")
(pad_color :type list :default (quote [0 0 0]))
)
(let [a frame-a
a-w (width a)
a-h (height a)
b-raw frame-b
b-w (width b-raw)
b-h (height b-raw)
;; Calculate scale based on resize mode and priority
scale-w (/ a-w b-w)
scale-h (/ a-h b-h)
scale (if (= resize_mode "stretch")
1 ;; Will use explicit dimensions
(if (= resize_mode "crop")
(max scale-w scale-h) ;; Scale to cover, then crop
(if (= priority "width")
scale-w
scale-h)))
;; For stretch, use target dimensions directly
new-w (if (= resize_mode "stretch") a-w (round (* b-w scale)))
new-h (if (= resize_mode "stretch") a-h (round (* b-h scale)))
;; Resize b
b-resized (resize b-raw new-w new-h "linear")
;; Handle fit (pad) or crop to exact size
b (if (= resize_mode "crop")
;; Crop to center
(let [cx (/ (- new-w a-w) 2)
cy (/ (- new-h a-h) 2)]
(crop b-resized cx cy a-w a-h))
(if (and (= resize_mode "fit") (or (!= new-w a-w) (!= new-h a-h)))
;; Pad to center
(let [pad-x (/ (- a-w new-w) 2)
pad-y (/ (- a-h new-h) 2)
canvas (make-image a-w a-h pad_color)]
(paste canvas b-resized pad-x pad-y))
b-resized))]
(if (= mode "alpha")
(blend-images a b opacity)
(blend-images a (blend-mode a b mode) opacity))))
(if (core:is-nil overlay)
frame
(let [a frame
b overlay
a-h (image:height a)
a-w (image:width a)
b-h (image:height b)
b-w (image:width b)
;; Resize b to match a if needed
b-sized (if (and (= a-w b-w) (= a-h b-h))
b
(image:resize b a-w a-h "linear"))]
(if (= mode "alpha")
(blending:blend-images a b-sized opacity)
(blending:blend-images a (blending:blend-mode a b-sized mode) opacity)))))