some tempfile optimizations
This commit is contained in:
@@ -9,31 +9,25 @@ if [[ "$1" = "e" ]]; then
|
|||||||
OUTFILE="$2"
|
OUTFILE="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
PARFILE="$(mktemp -u)"
|
PARFILE="$(mktemp -t 'YS-XXXXXXXX')"
|
||||||
ENCFILE="$(mktemp -u)"
|
[[ -z "$YS_PASS" ]] && read -rs -p 'Encryption password: ' YS_PASS
|
||||||
echo "Compressing and encrypting..."
|
echo "Processing..."
|
||||||
[[ -z "$YS_PASS" ]] && read -rs -p 'Password: ' YS_PASS
|
|
||||||
tar --use-compress-program='zstd -T0 -10' -cf - -- $* | \
|
tar --use-compress-program='zstd -T0 -10' -cf - -- $* | \
|
||||||
openssl aes-256-cbc -e -pbkdf2 -out "$ENCFILE" -pass "pass:$YS_PASS"
|
openssl aes-256-cbc -e -pbkdf2 -pass "pass:$YS_PASS" | \
|
||||||
echo "Adding redundancy..."
|
xpar -Je -i 3 -H blake2b > "$PARFILE"
|
||||||
xpar -Je -i 3 -H blake2b "$ENCFILE" "$PARFILE"
|
|
||||||
truncate -s $(( ( $(wc -c < "$PARFILE") + 7199 ) / 7200 * 7200 )) "$PARFILE"
|
truncate -s $(( ( $(wc -c < "$PARFILE") + 7199 ) / 7200 * 7200 )) "$PARFILE"
|
||||||
echo "Encoding video..."
|
|
||||||
ffmpeg -hide_banner -f rawvideo -pixel_format monob -video_size 320x180 -framerate 60 \
|
ffmpeg -hide_banner -f rawvideo -pixel_format monob -video_size 320x180 -framerate 60 \
|
||||||
-i "$PARFILE" -vf "scale=1280:720:flags=neighbor,format=monob" \
|
-i "$PARFILE" -vf "scale=1280:720:flags=neighbor,format=monob" \
|
||||||
-c:v libvpx-vp9 -lossless 1 -deadline realtime -speed 8 -row-mt 1 -aq-mode 0 \
|
-c:v libvpx-vp9 -lossless 1 -deadline realtime -speed 8 -row-mt 1 -aq-mode 0 \
|
||||||
-pix_fmt yuv420p -f webm "${OUTFILE}"
|
-pix_fmt yuv420p -f webm "${OUTFILE}"
|
||||||
rm -f "$PARFILE" "$ENCFILE"
|
rm -f "$PARFILE"
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
elif [[ "$1" = "d" ]]; then
|
elif [[ "$1" = "d" ]]; then
|
||||||
PARFILE="$(mktemp -u)"
|
echo "Processing..."
|
||||||
echo "Decoding video..."
|
[[ -z "$YS_PASS" ]] && read -rs -p 'Decryption password: ' YS_PASS
|
||||||
ffmpeg -hide_banner -i "$2" -vf "scale=320:180:flags=neighbor,format=monob" -f rawvideo "$PARFILE"
|
ffmpeg -hide_banner -i "$2" -vf "scale=320:180:flags=neighbor,format=monob" -f rawvideo - | \
|
||||||
echo "Restoring, decrypting and decompressing..."
|
xpar -Jdc | openssl aes-256-cbc -d -pbkdf2 -pass "pass:$YS_PASS" | \
|
||||||
[[ -z "$YS_PASS" ]] && read -rs -p 'Password: ' YS_PASS
|
tar --use-compress-program='zstd -T0' -xf -
|
||||||
xpar -Jdc "$PARFILE" | openssl aes-256-cbc -d -pbkdf2 -pass "pass:$YS_PASS" \
|
|
||||||
| tar --use-compress-program='zstd -T0' -xf -
|
|
||||||
rm -f "$PARFILE"
|
|
||||||
echo "Done!"
|
echo "Done!"
|
||||||
else
|
else
|
||||||
echo "Invalid mode! Use e or d"
|
echo "Invalid mode! Use e or d"
|
||||||
|
|||||||
Reference in New Issue
Block a user