Wednesday 3 July 2024

New script I'm working on.


 Above image is the output from a new script that I'm working on which is similar to other scripts that I've created recently but rather than working on a folder of images it grabs an image from your screen , hex edits it ( if you say yes), divides it into a grid of images and reassembles it rotates it in a random direction , then grabs another image from the screen and uses gmic xor to combine the first and second images. It does this and saves the image into new folder and carries on until you ctrl c the script. It requires imagemagick, scrot gmic cli and at the moment is linux only and runs from a bash terminal. Script below is very much a work in progress use at your own risk. ( ps my scripts can now be found on codeberg here )

 

#!/bin/bash
#screen grabbing desktop alter dimensions to suit
#
h=$(pwd)
echo $h
dd=$(date +%Y-%m-%d_%H%M%S)
mkdir $h/$dd
#Questions questions
echo -n "Screen size  1368x768 (s), medium 1600x900 (m), large 1920x1080 (l), box 768x768(1600x900) (b) ? : "
read sc
#
echo -n "Use Stereoscopic colour shifting (y/n) ? : "
read shft
#use splittor
echo -n "Use splittor (y/n) ? : "
read spl
#
echo -n "Make cubes (y/n) ? : "
read cn
#
echo -n "Use Rotation (y/n) ? : "
read ro
if [ $ro == "y" ] || [ $ro == "null" ]
then
#echo -n "Degrees to rotate (0-365) ? : "
#read dg
echo -n "Number of rotations ? : "
read numro
fi  
echo -n "Use Contra-rotation (y/n) ? : "
read cro
#
echo -n "Use gmic xor displacement (y/n) ? : "
read gmc
#
echo -n "multiple(m) or single(s) or none(n) hex Editing ? : "
read hex
if [ $hex == "s" ] || [ $hex == "null" ]
then
echo -n "Target value ? : "
read tr
echo -n "Image format to use ? : "
read f
fi
#

echo "Press CTRL+C to stop..."
#
for ((;;))
do
sleep 15
d=$(date +%Y-%m-%d_%H%M%S)
if [ $sc == "l" ] || [ $sc == "null" ]
then
scrot -z -a 0,0,1920,1080 $h/$dd/$d.png
cd $h/$dd/
 elif [ $sc == "m" ]
 then
 scrot -z -a 0,0,1600,900 $h/$dd/$d.png
cd $h/$dd/
elif [ $sc == "s" ]
then
 scrot -z -a 0,0,1368,768 $h/$dd/$d.png
cd $h/$dd/

elif [ $sc == "b" ]
then
 scrot -z -a 417,97,768,768 $h/$dd/$d.png
cd $h/$dd/
fi


if [ $shft == "y" ] || [ $shft == "null" ]
then
composite -stereo -50+20 $d.png $d.png result.png  
mv result.png $d.png
fi

if [ $hex == "s" ] || [ $hex == "null" ]
then
  to=$(openssl rand -hex 1)
mogrify -format $f $d.png
sed '0,/'$tr'/s//'$to'/' $d.$f > swap.$f
mogrify -format png swap.$f
rm swap.$f
rm $d.$f
mv swap.png $d.png
fi
if [ $hex == "m" ] || [ $hex == "null" ]
then
from=$(openssl rand -hex 1)
  to=$(openssl rand -hex 2)
mogrify -format ppm $d.png
sed 's/\x'$from'/\x'$to'\x'$from'/g' $d.ppm > swap.ppm
#sed '0,/'$from'/s//'$to'/' $d.ppm > swap.ppm
mogrify -format png swap.ppm
rm swap.ppm
rm $d.ppm
mv swap.png $d.png
fi
if [ $spl == "y" ] || [ $spl == "null" ]
then
mogrify -format ppm $d.png

split -n 24 $d.ppm
rm $d.ppm
cat xaa xac xab xae xad xag xaf xai xah xak xaj xam xal xao xan xaq xap xas xar xau xat xaw xav xax  > swap.ppm
mogrify -format png swap.ppm
rm swap.ppm
mv swap.png $d.png
rm xaa xab xac xad xae xaf xag xah xai xaj xak xal xam xan xao xap xaq xar xas xat xau xav xaw xax
fi
#
if [ $cn == "y" ] || [ $cn == "null" ]
          then
          gmic $d.png frame_cube , -o swap.png;
          mv swap.png $d.png;
          fi
if [ $ro == "y" ] || [ $ro == "null" ]
          then
          i=0
          while [ $i -lt $numro ]
            do
            ((i++))
            rnd=$((1 + $RANDOM % 360))
            convert $d.png -distort SRT $rnd rotate.png
            mv rotate.png $d.png
            done
          fi
#
if [ $gmc == "y" ] || [ $gmc == "null" ]
then
#rndx=$((1 + $RANDOM % 450))
#rndy=$((1 + $RANDOM % 800))
scrot -z -a 417,97,768,768 swap.png
if
[ $cro == "y" ] || [ $cro == "null" ]
then
rnd=$((1 + $RANDOM % 360))
convert swap.png -distort SRT -$rnd rotate.png
            mv rotate.png swap.png
fi
gmic $d.png swap.png  -blend xor -o swap2.png
mv swap2.png $d.png
rm swap.png
 

fi

cd $h/

done
 

 

 


Eigenstate 2 - more experiments with ffmpeg, x11grab and generating feedback on the linux desktop

These are the commandlines I used in an online  demonstration recently showing how simple tools can lead to visual complexity.  From a standard bash terminal on Devuan Linux ( not Debian)  4 with ffmpeg 4.4.x ( they need to be altered for ffmpeg 5 plus as there are differences in the way the commands need to be written and wont work without that also will only work with x11 not wayland will most probably not work in windows) 

simple x11 grab using ffplay 'ffplay -f x11grab -follow_mouse centered -framerate 10 -video_size 640x480 -i :0.0'

feeding the output of ffmpeg into ffplay

ffmpeg -f x11grab -follow_mouse centered -framerate 5 -video_size 1920x1060 -i :0.0 -f rawvideo -vcodec rawvideo -pixel_format bgr0 -video_size 1920x1060 - | ffplay -f rawvideo -vcodec rawvideo -pixel_format bgr0 -video_size 1920x1060 -

The more complicated command line also allows us to play with colour space by changing pixel format .

ffmpeg -f x11grab -follow_mouse centered -framerate 5 -video_size 1280x720 -i :0.0 -f rawvideo -vcodec rawvideo -pix_fmt monob -video_size 1280x720 - | ffplay -f rawvideo -vcodec rawvideo -pix_fmt monob -video_size 1280x720 -

in this case from a colour format bgr0 to a black and white dithered format monob
or we could change the output codec from rawvideo to a strange format like tmv ( created by enthusiasts to enable video playback on the original ibm 8088 powered pc)

ffmpeg -f x11grab -follow_mouse centered -framerate 5 -video_size 1280x720 -i :0.0 -f rawvideo -vcodec rawvideo -pix_fmt monob -video_size 1280x720 - | ffplay -f rawvideo -vcodec tmv -pix_fmt monob -video_size 1280x720 -

or we could use ffmpegs displacement function

ffmpeg -f x11grab -follow_mouse centered -framerate 23 -video_size 640x640 -i :0.0 -f x11grab -follow_mouse centered -framerate 23 -video_size 640x640 -i :0.0 -lavfi '[1]split[x][y],[0][x][y]displace' -f rawvideo -pix_fmt pal8 - | ffplay -f rawvideo -pix_fmt pal8 -vf "rotate=1.23" -s 640x640 -

 FINAL WINDOWS used in demonstration

3 vertical one square rotating

normal vertical

ffmpeg -f x11grab -follow_mouse centered -framerate 5 -video_size 640x1060 -i :0.0 -f rawvideo -vcodec rawvideo -pix_fmt bgr0 -video_size 640x1060 - | ffplay -f rawvideo -vcodec rawvideo -pixel_format bgr0 -video_size 640x1060 -

hflip vertical

ffmpeg -f x11grab -follow_mouse centered -framerate 5 -video_size 640x1060 -i :0.0 -f rawvideo -vcodec rawvideo -pix_fmt bgr0 -video_size 640x1060 - | ffplay -f rawvideo -vcodec rawvideo -pixel_format bgr0 -vf hflip  -video_size 640x1060 -

vflip vertical

ffmpeg -f x11grab -follow_mouse centered -framerate 5 -video_size 640x1060 -i :0.0 -f rawvideo -vcodec rawvideo -pix_fmt bgr0 -video_size 640x1060 - | ffplay -f rawvideo -vcodec rawvideo -pixel_format bgr0 -vf vflip  -video_size 640x1060 -

square monob rotating

ffmpeg -f x11grab -follow_mouse centered -framerate 23 -video_size 640x640 -i :0.0 -f x11grab -follow_mouse centered -framerate 23 -video_size 640x640 -i :0.0 -f rawvideo -pix_fmt monob - | ffplay -f rawvideo -pix_fmt monob -vf "rotate=1.23" -s 640x640 -

Using simple tools we can convert the desktop into a complex environment to experiment with feedback and by adding video playback we can also make it even more complex and rich.

And experimenting with ffmpeg filters can take it even further.

This was made using the above tools 


 Eigenstate 2

 

Mark Fisher – ‘Ghosts of my life’, Fukuyama’s ‘End of history’ and rebooting the future with glitch art.

Note- this was the introduction I gave during a recent online discussion with Verena Voigt ( https://www.verena-voigt-pr.de/ ) a...