From 43a3d03d9b9fb49616b807553fa624785530c5ae Mon Sep 17 00:00:00 2001 From: Luxferre Date: Tue, 26 May 2026 15:12:47 +0300 Subject: [PATCH] first upload --- README.md | 9 +++++++++ ys | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 README.md create mode 100755 ys diff --git a/README.md b/README.md new file mode 100644 index 0000000..8e92cb4 --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Bash goodies: a useful collection of single-file, Bash shell scripts + +This is a set of Bash-specific scripts for quality-of-life improvement. + +For POSIX shell compatible scripts, see the [sh-goodies](https://codeberg.org/luxferre/sh-goodies) repo. + +## List + +* [YouShare](./ys): a way to securely store any set of files/directories inside a video diff --git a/ys b/ys new file mode 100755 index 0000000..3968f6d --- /dev/null +++ b/ys @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +# YouStore: convert any set of files/dirs into a video file +# that's also (somewhat) resistant to re-encoding +# Usage: ys [e|d] [vidfile] [path...] [path...] +# Dependencies: tar, zstd, truncate (coreutils), xpar, openssl, ffmpeg +# Created by Luxferre in 2026, released into the public domain + +BASEW=320 # base frame width +BASEH=180 # base frame height +SCL=4 # frame scale factor +FR=60 # frame rate in the output video +CODEC_PARAMS='-c:v libvpx-vp9 -lossless 1 -deadline realtime -speed 8 -row-mt 1 -aq-mode 0 -pix_fmt yuv420p -f webm' + +BPF=$(( BASEW * BASEH / 8 )) # bytes per frame +if [[ "$1" = "e" ]]; then + OUTFILE="$2" + shift + shift + ARCHFILE="$(mktemp -u)" + PARFILE="$(mktemp -u)" + ENCFILE="$(mktemp -u)" + echo "Compressing..." + tar --use-compress-program='zstd -19' -cf "$ARCHFILE" -- $* + echo "Encrypting..." + [[ -z "$YS_PASS" ]] && read -rs -p 'Password: ' YS_PASS + openssl aes-256-cbc -e -pbkdf2 -in "$ARCHFILE" -out "$ENCFILE" -pass "pass:$YS_PASS" + echo "Adding redundancy..." + xpar -Je -i 3 -H blake2b "$ENCFILE" "$PARFILE" + truncate -s $(( ( $(stat -c%s "$PARFILE") + BPF - 1 ) / BPF * BPF )) "$PARFILE" + echo "Encoding video..." + ffmpeg -hide_banner -f rawvideo -pixel_format monob -video_size ${BASEW}x${BASEH} -framerate $FR -i "$PARFILE" -vf "scale=iw*${SCL}:ih*${SCL}:flags=neighbor,format=monob" $CODEC_PARAMS "${OUTFILE}.webm" + rm -f "$ARCHFILE" "$PARFILE" "$ENCFILE" + echo "Done!" +elif [[ "$1" = "d" ]]; then + PARFILE="$(mktemp -u)" + echo "Decoding video..." + ffmpeg -hide_banner -i "$2" -vf "scale=${BASEW}:${BASEH}:flags=neighbor,format=monob" -f rawvideo "$PARFILE" + echo "Restoring, decrypting and decompressing..." + [[ -z "$YS_PASS" ]] && read -rs -p 'Password: ' YS_PASS + xpar -Jdc "$PARFILE" | openssl aes-256-cbc -d -pbkdf2 -pass "pass:$YS_PASS" | tar --use-compress-program='zstd' -xf - + rm -f "$PARFILE" + echo "Done!" +else + echo "Invalid mode! Use e or d" +fi