@bytes_1:<!DOCTYPEhtml>
<html lang=en>
<meta charset=utf8>
<title>A bash script on the blockchain</title>
<body>
<pre>
#!/bin/bash
#define variables
#name of input file
input=clip.mp4
#effect used for sonification (check https://www.vacing.com/ffmpeg_audio_filters/index.html or https://www.ffmpeg.org/ffmpeg-filters.html)
effect="acrusher=level_in=18:level_out=2:bits=1:mode=log:aa=1,adelay=1500"
PS3="Select the operation or hit Ctrl+C to exit: "
#string for hex editing s//g Hex numbers are delimted by / and start with \x this would be "DA" to "EDA" in a hexeditor
hex="s/\xDA/\x0E\xDA/g"
#present user with options
select opt in hexediting sonification; do
#define what happens when each option is selected
case $opt in
hexediting)
#make frames directory in current directory
mkdir frames
#convert mp4 to frames (this will search the entire dir for mp4 files and will overwrite the BMP frames if there's more than one mp4, we could also just do ffmpeg -i $input frames/%05d.bmp)
for i in *.mp4
do ffmpeg -i $i frames/%05d.bmp
done
#hex edit the frames (in place in the frames directory)
for i in frames/*.bmp
do sed "$hex" $i > temp
mv temp $i
done
#convert the glitched frames back into video
ffmpeg -r 25 -i frames/%05d.bmp -pix_fmt yuv420p -c:v h264 -q:v 0 hex_output.mp4 -y
#translant source file audio onto glitched and baked video
ffmpeg -i hex_output.mp4 -i $input -c copy -map 0:v:0 -map 1:a:0 -shortest hex_output_with_sound.mp4 -y
;;
sonification)
#convert mp4 to raw
ffmpeg -i $input -c:v rawvideo -pix_fmt yuv420p 1920x1080-raw-prep.yuv -y
#Do sonification
ffmpeg -f alaw -i 1920x1080-raw-prep.yuv -af "$effect" -f alaw sonified-output.yuv -y
#convert the glitched ra w back into video
ffmpeg -f rawvideo -r 30 -pix_fmt yuv420p -s 1920x1080 -i sonified-output.yuv -c:v h264 -q:v 0 sonified-bake.mp4 -y
#transplant source file audio onto glitched and baked video
ffmpeg -i sonified-bake.mp4 -i $input -c copy -map 0:v:0 -map 1:a:0 -shortest sonification_output_with_sound.mp4 -y
;;
esac
done
</pre>
storage bytes