Wednesday 28 July 2021

Mantissa - Self capturing displacement shell-script

 This a shell-script I've been working on for a few days , it still needs a lot of tweaking so as presented this is just the rough version , but it does work , I'll post a video of it working on my peertube channel today and add a link later. And its later so heres the link https://tube.tchncs.de/w/1jrcqpHKgzg2AdafJ6upzz

What does it do ? The script first calls two web cams via stub scripts, the first at 1280x720 the second at 960x540 , placed in the centre of the screen. Its important to state that this is customised for a 1600x900 resolution widescreen monitor , and I've customised where terminals etc pop up and stay resident on that basis to leave the 1280x720 window in the middle of the screen clear for display and capture , you'll notice there's a third terminal called which runs the recording script which I use in conjunction with xdotool to maintain its focus. 

Once all that is running the cameras run continuously , both have a maximum resolution of 640x480 but running them via ffplay allows me to change that and that process gives some nice glitchy effects . The capturing section of the script first creates a seed file then moves to a loop until halted which takes the seed file and applies it in a loop to the video captured in real time , but always a step behind and using the real time capture as an input for a displacement function , so the displacement map created becomes more and more glitched out as the script continues , it also saves the files it creates to a secondary folder , so if you attempt to use this script you will need to change some values to reflect that and the size of your screen - xwininfo is your friend

All this on parabola running on a Dell 9010 with built in graphics , a 250gb ssd, 8gb ram and two playstation 3 cameras with no modifications ( though it runs with my circuit bent cameras quite well ) .

( you need the main script and two sub scripts in the same folder for this to run correctly )

Main script (mantissa.sh)

#! /bin/bash
# Note this works on 1600x900 res screen adjust win geometries by grabbing with xwininfo
i=0

lxterminal --geometry=17x24+0-32 -e ./mantissacam0.sh
sleep 10
lxterminal --geometry=17x24+0+0 -e ./mantissacam1.sh
lxterminal --geometry=17x24-0+0
sleep 30

# Grab seed file
xdotool mousemove 1525 6
xdotool mousedown 1
sleep 1
xdotool type "recordmydesktop -x 161 -y 112 --width 1280 --height 720 --v_quality 30 --overwrite --no-sound --on-the-fly-encoding -o mantissa-$i.ogv"
sleep 5
xdotool key Return
sleep 30
xdotool key ctrl+c
sleep 1

#save seed file
ffmpeg -i mantissa-$i.ogv -c:v libxvid -q 23 /home/crash-stop/mantissa/mantissa-seed.mp4

#main loop

while true
do
((i++))

#sleep 2
#get window corners and window size with xwininfo
xdotool mousemove 1525 6
xdotool mousedown 1
sleep 1
xdotool type "recordmydesktop -x 161 -y 112 --width 1280 --height 720 --v_quality 30 --overwrite --no-sound --on-the-fly-encoding -o mantissa-$i.ogv"
sleep 5
xdotool key Return
sleep 30
xdotool key ctrl+c
sleep 1

#ffmpeg -i mantissa-$i.ogv -c:v libxvid -q 23 /home/crash-stop/mantissa/mantissa-$i.mp4
ffmpeg -i mantissa-$i.ogv -i /home/crash-stop/mantissa/mantissa-seed.mp4 -lavfi '[1]split[x][y],[0][x][y]displace' /home/crash-stop/mantissa/mantissa-$i.mp4
mpv --geometry=1280x720+161+112 /home/crash-stop/mantissa/mantissa-$i.mp4
cp /home/crash-stop/mantissa/mantissa-$i.mp4 /home/crash-stop/mantissa/mantissa-seed.mp4
done

Subscript 1 (mantissacam0.sh)

#! /bin/bash

ffmpeg -i /dev/video1 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 960x540 - | sed 's/f/18/g' | ffplay -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 1280x720 -

Subscript 2 (mantissacam1.sh)  

#! /bin/bash
ffmpeg -i /dev/video0 -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 960x540 - | sed 's/f/18/g' | ffplay -f rawvideo -vcodec rawvideo -pix_fmt yuv420p -s 960x540 -


( Notice that the two subscripts also glitch the output of the two webcams using sed - obviously you can either remove that or change the values to alter effects )

ikillerpulse ( requires tomato.py in working directory)

I've been working on this script for the last week or so. What does it do? It takes an input video/s,  converts to a format we can use f...