From 32451a783fd539d7e4ce78e26a6789eeaca36bb9 Mon Sep 17 00:00:00 2001 From: efim Date: Fri, 16 Aug 2024 10:34:42 +0000 Subject: [PATCH] before trying to create elements separately --- gstreamer/tutorial-hello-world.lisp | 39 ++++++++++-------- notes.org | 62 +++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 16 deletions(-) diff --git a/gstreamer/tutorial-hello-world.lisp b/gstreamer/tutorial-hello-world.lisp index c350d17..6601d40 100644 --- a/gstreamer/tutorial-hello-world.lisp +++ b/gstreamer/tutorial-hello-world.lisp @@ -61,23 +61,16 @@ ;; videotestsc worked ;; and error i got was from trying to set :null ? but it should be correct enum ;; oh well, ok -(defun for-screencast () +(defun for-screencast (stream-num) (gir:invoke (*gstreamer* 'init) '()) - (let ((pipeline (gir:invoke (*gstreamer* 'parse-launch) - "pipewiresrc path=46 ! videoconvert ! autovideosink" - ;"playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm" - ))) - (gir:invoke (pipeline 'set-state) - (gir:nget *gstreamer* "State" :playing)) - ;; (let* ((bus (gir:invoke (pipeline 'get-bus))) - ;; (msg (gir:invoke (bus 'timed-pop-filtered) - ;; (gir:nget *gstreamer* :clock-time-none) - ;; (list - ;; (gir:nget *gstreamer* "MessageType" :error) - ;; (gir:nget *gstreamer* "MessageType" :eos)))))) - ;; (gir:invoke (pipeline 'set-state) - ;; (gir:nget *gstreamer* "State" :paused)) - )) + (let* ((pipeline + (gir:invoke (*gstreamer* 'parse-launch) + (format nil "pipewiresrc path=~A ! videoconvert ! videobox name=move ! autovideosink" stream-num) + ;"playbin uri=https://gstreamer.freedesktop.org/data/media/sintel_trailer-480p.webm" + )) + (move-element (gir:invoke (pipeline 'get-by-name) "move"))) + (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) + (values pipeline move-element))) ;; well, pipewire is not part of what's added to env ;; not sure if i can add it @@ -87,3 +80,17 @@ ;; i can try to add pipewire, but then would it work with the screen share running on system server? ;; it did work. wowy. ok ;; cool. now i'm kind of at the point of python example :D + +;; let's generalize, when stream is not passed, use the testsrc +(defun moving-cast (&optional stream-num) + (gir:invoke (*gstreamer* 'init) '()) + (let* ((source (if stream-num + (format nil "pipewiresrc path=~A" stream-num) + "videotestsrc")) + (pipeline + (gir:invoke (*gstreamer* 'parse-launch) + (format nil "~A ! videoconvert ! videobox name=move ! autovideosink" source)))) + ; (format t "~A" (gir:nget pipeline 'get-state)) + (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) + pipeline)) + diff --git a/notes.org b/notes.org index c963c0c..8964bcd 100644 --- a/notes.org +++ b/notes.org @@ -210,3 +210,65 @@ so. tried removing all from shell env, then not found namespace Gst (defvar *gstreamer* (gir:require-namespace "Gst")) so. yeah. maybe i need to install dev headers or something? + +** so. for moving the video around. chatgpt recommended something named 'videobox' + +like i can declare it in the pipeline and then get reference to it and use to set video coordinates, huh? +https://gstreamer.freedesktop.org/documentation/videobox/index.html?gi-language=python +the thing exists but i have zero idea whether it's accessible in a way that's recommended +#+begin_src lisp +(defun for-screencast () + (gir:invoke (*gstreamer* 'init) '()) + (let* ((pipeline (gir:invoke (*gstreamer* 'parse-launch) + "pipewiresrc path=49 ! videoconvert ! videobox top=0 left=0 right=0 bottom=0 ! videoconvert ! autovideosink" + )) + (videobox (gir:invoke (pipeline 'get-element-by-name) "videobox"))) + ;; Set the initial state to playing + (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) + + ;; Function to move the video + (defun move-video (top left) + (gir:invoke (videobox 'set-property) 'top top) + (gir:invoke (videobox 'set-property) 'left left)) + + ;; Example: Move the video 10 pixels down and 20 pixels to the right + (move-video 10 20))) +#+end_src + +and similar advice from claude, huh +#+begin_src lisp +(defun for-screencast () + (gir:invoke (*gstreamer* 'init) '()) + (let* ((pipeline (gir:invoke (*gstreamer* 'parse-launch) + "pipewiresrc path=49 ! videoconvert ! videobox name=move ! videoscale ! autovideosink")) + (move-element (gir:invoke (pipeline 'get-by-name) "move"))) + (gir:invoke (pipeline 'set-state) (gir:nget *gstreamer* "State" :playing)) + (values pipeline move-element))) + +(defun move-video (move-element left top) + (gir:set-property move-element "left" left) + (gir:set-property move-element "top" top)) + +;; Usage: +(multiple-value-bind (pipeline move-element) (for-screencast) + ;; Move video 50 pixels to the right and 30 pixels down + (move-video move-element 50 30) + ;; Your main loop or other logic here + ) +#+end_src + +let's try this out + +* [2024-08-16 Fri] + +** new day of the vacation +the experiment with moving the video, right? + +could it be that both examples are fake? i don't seem to find both 'get-element things + +trying to find anything about dynamism in gstreamer +https://coaxion.net/blog/2014/01/gstreamer-dynamic-pipelines/ +looks like this is about changing elements of the pipeline + +and it's possible that parameters of the pipeline elements (pads?) are also static +