In an older version of FFmpeg it was possible to glitch the image with JPEG-LS codec. Newer versions of FFmpeg don’t work anymore in this way, so one must download an old version and compile it (keep it local) – here 2.0.7 is used.
This script takes a video file as an argument, extracts frames, glitches them, and gathers frames back into a video file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
#!/bin/bash # jpeg-LS glitcher by nova@deviator.si http://deviator.si # check existence of input argument # the $# variable will tell you the # number of input arguments the script was passed. if [ $# -eq 0 ] then echo "Error. No arguments supplied. Please define a video" exit 1 fi # does the movie file actually exist? if [ ! -f $1 ]; then echo "Error. File not found!" exit 1 fi # get this session's "ID" SID=`date +%Y%m%d_%H%M%S` # jpegls glitch needs an older ffmpeg FFMPEG=/home/random/src/ffmpeg/ffmpeg-2.0.7/ffmpeg # create folder for this session DIR=jpegls_$SID echo "+++ creating folder $DIR ..." mkdir $DIR # create tmp folder echo "+++ creating folder $DIR/tmp/ ..." mkdir $DIR/tmp/ echo "+++ extracting all frames as images..." echo echo "----------------------------------------------------------" echo ffmpeg -loglevel 16 -i $1 $DIR/tmp/frame%5d.jpg echo echo "----------------------------------------------------------" echo "+++ processing each image..." for i in $DIR/tmp/*.jpg do echo "processing $i " $FFMPEG -loglevel 16 -i $i -pred 80 -c:v jpegls $i.jpgls.jpg ffmpeg -loglevel 16 -i $i.jpgls.jpg -c:v png $i.png done echo echo "----------------------------------------------------------" echo "+++ putting frames back into a movie ... " ffmpeg -loglevel 16 -i $DIR/tmp/frame%5d.jpg.png $DIR/$SID.$1 echo echo "+++ removing temporary folder ..." rm -rf $DIR/tmp/ echo "\n--- end of the program. " |