Friday 28 June 2024

Basic glitch art tool kit

This is an updated rewrite of an earlier post from 2021 in response to a question I got asked on Tumblr recently about getting started making glitch art using non proprietary software - hopefully it will be useful and furnish you the reader with a good toolkit generally for making glitch art on Windows machines without the need for paying for or obtaining cracked versions of proprietary software which restricts your freedom to do with the hardware you own  what you will. Its also a  basis for starting to move away from closed source operating systems in general.

* When I talk about windows I mean Windows 10 , not eleven, not doing that , and when 10 becomes eol in less than a year that's the end of me writing guides for Windows. Ill just stick to Linux.

I use mainly linux myself and my work is mainly script based, I keep a codeberg repository for the scripts I use the most, some of which are also for windows 10, details in the readme , but most could be adapted for Windows 10 quite easily. My codeberg is here https://codeberg.org/crash-stop


Hardware requirements - I believe in recycling and reusing old equipment  as much as possible , my most modern desktop is a 4th gen i3 with 8gb of ram using the built in graphics from that chip , I've succesfully created and edited video on older equipment though having said that the minimum to achieve anything useful would be a late gen core2duo with 4gb of ram , one of my laptops ( I call it a potato) that I used for testing until recently  rocked an elderly celeron N2840 ( essentially a souped up atom processor)  and that could be used to edit and render very short videos and run hex editing programs in real time quite successfully  running Linux and batch scripts and such like with Windows 10 ( though these days ie 2024+ really a second gen i3 and 8gb ram plus is minimum on windows 10)  . Know your architecture are you running 32 bit or 64 bit ? I make no judgements but all the links I've given are generally for 64bit software , there are 32bit versions available and pages will give you links for both mostly so remember to check before you download and get frustrated that some software won't install.

For both Windows and Linux users it can be helpful to have access to either a built in webcam or an external webcam 

For windows 10 when installing software be aware that a recent update to Windows 10 means some software may trigger a software from unknown source alert in a dark blue box and you will have to allow the software to be installed by clicking through that message even though the software is from a trustworthy source. That being said the first piece of software to install is 

1)Notepad++ which is useful for reading readmes and for creating bash scripts though my preferred windows and linux editor is geany , this is installed in the usual windows way get it here http://notepad-plus-plus.org/ 

It will also help if you want to start getting into experimenting with the wordpad effect ( the best introduction for that is sTallio's here http://blog.animalswithinanimals.com/2008/08/databending-and-glitch-art-primer-part.html  though sTAllio refers to using photoshop raw as a format if you use something like ppm or bmp they are near raw formats just open them in and notepad ++ alter some stuff, save with new name and see what happens !!) 

you might also want to add a gui hex editor ( on linux I use bless) but this is a nice basic one for windows to start with https://mh-nexus.de/en/hxd/  start slowly, don't change to much at once  and remember to avoid the header and save as a new file.

2)After that install git for windows which will give us the bash like terminal  Git-Bash which we can use  to manipulate video with hex editing , ffmpeg and ffglitch/ffgac from the command line as its better than windows powershell and includes some of of the basic linux/unix command line applications we will need - get git bash here - https://www.atlassian.com/git/tutorials/git-bash

3) Windows , unlike Linux  doesn't really come with a package manager  so for things like ffmpeg its easier to install a third party package manager like Chocolatey . To install chocolatey you will need to open windows powershell as administrator ( quick guide here https://www.howtogeek.com/662611/9-ways-to-open-powershell-in-windows-10/ ) - so go to win icon in bottom left hand corner click on it and in search bar to the right type powershell it comes out top of list , right click and open as administrator then go here https://chocolatey.org/install and follow the install instructions carefully. ( you can copy and paste the commands from there into windows powershell) read prompts during installation carefully and answer Y when it asks. Keep powershell open as we are now going to install more interesting stuff

4) Having installed that keep powershell open and go https://community.chocolatey.org/packages and search for ffmpeg ( unless you already have it installed , in which case make sure you have it added to path of which more in a moment) find the command to install ffmpeg ( you should choose the latest version I use  ffmpeg 4.4 but that's for compatability with older scripts ) then copy and paste that into powershell opened as administrator which should be ' choco install ffmpeg ' ( without the quotemarks)  follow the prompts and answer 'y' when asked 

5)  After ffmpeg search for and install, using chocolatey and powershell ,  imagemagick 'choco install imagemagick', and shotcut 'choco install shotcut' and python 'choco install python' , python is a programming language which we need to run Tomato a datamoshing tool by Kaspar Ravel, Shotuct is an open-source video editor, which has some interesting filters and rendering profiles  but kdenlive is probably easier to use but that can be downloaded from its website .  Most of these applications  have their own installers but its easier to download and install them via chocolatey, but for completeness sake their websites are 
Imagemagick image editor - https://imagemagick.org/index.php
shotcut video editor - https://www.shotcut.org/
 
You might want to install sox audio editor ( handy for sonification in scripts if you arent using ffmpeg and Vedran Gligos megaglitchatron script here  ) but its kind of tricky to install on windows to use via git bash. You need to download the portable version sox-14.4.2-win32.zip extract it then copy the extracted files from within the folder and paste them in C:\Program Files\Git\usr\bin ( presuming you have git-bash for windows installed if not you will need to install that first ) we can also do the same for gmic cli from here https://gmic.eu/download.html download the cli Command-line interface (CLI): zip .
 
A word on paths , if you already have python and ffmpeg installed via their own discreet installers and not chocolatey  then make sure you have them added to your system path so we can access them anywhere via the terminal shell git-bash,  this is easily done - this is a good guide here https://medium.com/@kevinmarkvi/how-to-add-executables-to-your-path-in-windows-5ffa4ce61a53
 
4a) Video editing software   

If you've read through this previously you will notice I haven't included openshot in the list of software to install , openshot though good is particularly buggy on Windows and crashes a lot  instead for video editing download Kdenlive from here https://kdenlive.org/en/ its also available for Linux. A good introduction to completely libre and opensource video editors for Linux , Windows and MacOS can be found here https://itsfoss.com/open-source-video-editors/  personally on Linux I use flowblade , and I'd recommend that for Linux users as its the most stable I've found and copes with larger files really well ( but isn't great for using with odd dimensions so its essential when using it I've found to pre-resize all the clips you'll be working with with something like handbrake) , Kdenlive is probably the better choice.

6) Close powershell and Install in the normal windows way The gimp from here and audacity from here
and Handbrake from here ( handbrake is a really handy gui for re-encoding and transcoding video it may ask you to install a .net library when you first go to start it - just say yes and follow the links to the download you need - ie .net to run desktop apps)   and Transmission bittorrent client from here
On first running Transmission on windows a windows defender pop up will appear , press the allow access button with shield to allow transmission to connect to the internet - transmission is a safe bittorrent client we will use to download video from our source of choice if needed . 
(I'm a little wary of recommending Audacity because of certain controversy's over its management and direction over the last year but it is still open source for now and until a stable fork is created it will do .)
 
 
 
addenda - Audacity 

There is a known problem with Audacity in windows in that to import certain files like ogg audio or m4a we need to have ffmpeg installed , unfortunately the version it requires is older and slightly different to the one we installed using chocolatey so we will have to download and install a different version for audacity to reference . Issue and links here https://manual.audacityteam.org/man/installing_ffmpeg_for_windows.html. Installer is here https://lame.buanzo.org/ffmpeg64audacity.php

 
Audacity and sonification - online tutorial here by @kindred cameras https://www.youtube.com/watch?v=Z_Rut5gjwfE  and here by vaeprism https://www.youtube.com/watch?v=4iSe5qy8VwY&t=70s
 
7) Download and install obs-studio from here  https://obsproject.com/
Handy for making desktop videos and for capturing the ephemeral glitches we get when hex editing video and playing it back live using ffplay 

8) If you don't already have Vlc video player installed do so find that here useful for video playback and screenshots. If you dont like using vlc and want something simpler you could try mpv . You can install mpv via chocolatey ie 'choco install mpv' or go to their website and follow the links ( but chocolatey is easier and you don't have to mess with adding it to path ) https://mpv.io/

9) Processing , its one of the tools i use a lot so download that here but make sure to download version 3.54 not the newer 4.0 beta 1 . Processing does not come with an installer but instead comes packaged as a zip file so when downloaded unzip it and look for the exe file to start it, you can either pin that to your taskbar or as a shortcut on your desktop once started you will need to install several libraries (I will explain how to later on.)  There is a difference in how processing stores sketchbook files in Windows compared to Linux , this is important as on Linux processing creates a folder called sketchbook and that is stored in the top directory of your home folder, on Windows sketches that you create are saved and stored in your home folder here /c/Users/yourusername/Documents/Processing/

10) Finally go here and download ffglitch/ffgac , once its downloaded, unzip it and leave it there until needed as its a standalone binary which doesn't need installing ( you might need to install 7zip to unzip it as the binary is zipped using that 7zip here https://www.7-zip.org/  and while we're at it grab Kaspar Ravels tomato as well , download it from here https://github.com/itsKaspar/tomato
( click on the green window on the right hand side which says code and click Download Zip)


 Linux in many ways is so much simpler and already has much of what we need installed, such as bash and the basic gnu coreutils that installing git-bash on windows gives us more info on gnu-coreutils here its an altogether more flexible environment for making glitch art  given that the core of glitch art is about  finding error through the misuse of tools , or rather using tools in a way in which they were not intended. 

Anyways Linux has diverse distributions and package managers but chief amongst those are either debian based or arch based systems . On Ubuntu, Debian and linuxmint my main method of installing software is from the command-line so fire up a terminal and do ( depending on what you do or dont have installed)  presuming you are running Debian 10 or 11, Ubuntu 18.04 and above   and Linuxmint 19.3 and above ( should also hold true for MXlinux and Devuan and derivatives) issue this command from any terminal:

Sudo apt install ffmpeg imagemagick vlc mpv handbrake sox audacity kdenlive flowblade obs-studio transmission
 
type in your password when asked and hit enter and that's pretty much it . 

I've added mpv video player to the list for Linux as I've noticed of late especially in Linuxmint 19.3 and above vlc has become very unreliable in use.

Shotcut is generally not available via Linux package managers and rather than trying to install from source or adding cumbersome ppas its probably easier just to install via flatpak find that here https://flathub.org/apps/details/org.shotcut.Shotcut
 
If you are using arch based distros you probably don't need any instructions on how to install programs or use package managers  . On parabola Linux I generally use a simple 'sudo pacman -S packagename' command or run octopi package manager and search for whatever package it is that I want. I install flatpaks manually from the command line a good guide from the arch wiki can be found here
 

Installing processing on Linux is actually pretty similar to that on windows in some ways, except when its unpacked you can then run the install.sh file by either right clicking and opening a terminal in the folder that has  just been unpacked or opening a terminal and cd-ing to that folder and issuing this command './install.sh' which will install processing for the current user and leave a shortcut on your desktop and an entry in the programming section of your applications list - you can start processing by clicking on either link.

Once you have processing on either windows or Linux installed and started you will need to install certain libraries. Find tools in the menu running from left to right at the top of the blank sketch window that has opened after startup and find tools, click on that and  from that drop down menu after clicking choose add tool, another window will open titled ' Contribution manager ' click on the tab that says ' Libraries' scroll down and find the entry that says 'Video | GStreamer-based video library for Processing ' click on that then find the button that says install, click on that and wait for the library to install, then click on entry just below it titled ' Video Export | Simple video file exporter ' then click on install again - this should give you the ability with the right script to initialize and use a webcam for input . To test that use the script below by cutting and pasting it into the open blank sketch making sure you have a webcam attached to your desktop pc or laptop then pressing the start button above the test window shaped like a cassette players start button . All being well after a short delay you should see video playback and a little glitchiness ! This is a basic sketch  I use , it needs a webcam.
 
import processing.video.*;
  
    Capture video;                  
                    
    void captureEvent(Capture video) {
    video.read();
    }
   
    void setup() {
       size(640, 480);
       video = new Capture(this, width, height);
        video.start();
    
    }

    void draw() {
  
  video.get();
      //background(0);
     video.loadPixels();
      for (int y = 0; y<height; y++) {
        for (int x = 0; x<width; x++) {
          int loc = x + y*video.width;
         
          float r = red (video.pixels[loc]);
          float g = green (video.pixels[loc]);
          float b = blue (video.pixels[loc]);
          float av = ((r+g+b)/3);

         pushMatrix();
        translate(x,y);
      
          stroke(r,g,b);
          float n = (av+r)/360;
          if (r > 100 && r < 250)
          {
            square(0,0,0);
         
         
          }
       
        popMatrix();
         
        }
      }
 
    } 
 
 
* You might also want to go to  the contribution manager and install from the examples tab the first set of examples ' The coding Book' and also ' The nature of code' by Daniel Shiffman , The coding book gives examples of fun things like slit scan and time displacement which are a good basis for starting points for code for glitch art in processing.

Mac OS - I have no real  experience of using macs or any apple products, and as inclusive as I wish to be software wise I can't help finding Apples walled garden approach to hardware and software a big turn off and contrary to a lot of my views on open source and software and hardware freedom in general, that being said MAC OS being unix based it has some similarities with linux and there is a package installer which should help you install some of the programs outlined above find that here https://brew.sh/

It might also be helpful to look at and understand the concepts behind bash scripting for which an earlier Blog post of mine was written in response to a question from a user on Reddit on how I make some of my still images and specifically if it could be done on Windows find that here ( though it does repeat some of the information above for software requirements the parts on bash scripting and permissions hold true for Linux as well ) https://crash-stop.blogspot.com/2021/05/quick-and-dirty-guide-to-using-shell.html  and the next blog post on from that which illustrates the script itself https://crash-stop.blogspot.com/2021/05/bash-script-for-sonification-images.html
 
 

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 ra...