update several shell scripts

This commit is contained in:
Michele Guerini Rocco 2020-07-22 14:43:23 +02:00
parent 04a62c834b
commit 15deaadc5f
Signed by: rnhmjoj
GPG Key ID: BFBAF4C975F76450
4 changed files with 42 additions and 51 deletions

23
scripts/cut-video Executable file
View File

@ -0,0 +1,23 @@
#!/bin/sh
ts2sec() {
IFS=:; set -- $1
echo $(($1*60*60 + $2*60 + $3))
}
SRC="$1"
START="$2"
STOP="$3"
# Calculate the segment time (in seconds)
SPAN="$(($(ts2sec "$STOP") - $(ts2sec "$START")))"
# Generate an output filename
OUT="$(basename "$SRC" .mkv)-cut.mkv"
# Cut exactly the segment requested into $OUT.
ffmpeg -i "$SRC" -ss "$START" -t "$SPAN" -c copy \
-c:v libx265 -preset slow -crf 23 \
-c:a libopus -b:a 96k -ac 2 -ar 48000 -y -- "$OUT"
ls -lh "$SRC" "$OUT"

View File

@ -1,50 +0,0 @@
#!/usr/bin/env nix-script
#!>zsh
#! shell | zsh curl haskellPackages.cabal-install
# functions
conf(){ cat *.cabal | grep -Po "^$1:\s+\K.+" }
input(){ read "reply?$1 "; echo ${reply:-$2} }
inputpw(){ echo -n "$1 " >&2; scat --silent --nocode -n 24 -S $2; echo >&2 }
# parameters
package=$(conf name)
version=$(conf version)
author=$(conf author)
# authentication
user=$(input "user ($author):" $author)
password=$(inputpw "password:" hackage)
cabal configure &&
cabal build &&
cabal haddock \
--hyperlink-source \
--html-location='/package/$pkg-$version/docs' \
--contents-location='/package/$pkg'
S=$?
if [ "$S" = "0" ]; then
cd dist/doc/html
ddir="$package-$version-docs"
cp -rf $package $ddir &&
tar -cz --format=ustar -f "$ddir.tar.gz" $ddir
CS=$?
if [ "$CS" -eq "0" ]; then
echo "Uploading to Hackage..."
curl \
-X PUT \
-H 'Content-Type: application/x-tar' \
-H 'Content-Encoding: gzip' \
-u "$user:$password" \
--data-binary "@$ddir.tar.gz" \
"https://hackage.haskell.org/package/$package-$version/docs"
exit $?
else
echo "Error when packaging the documentation."
exit $CS
fi
else
echo "Error when trying to build the package."
exit $S
fi

18
scripts/rec Executable file
View File

@ -0,0 +1,18 @@
#!/bin/sh
record() {
sleep 2
ffmpeg -f x11grab -r 30 -s 1920x1080 -i :0.0 -f alsa -i recorder \
-c:v libx264 -preset ultrafast \
-c:a libopus -b:a 96k -ac 2 -ar 48000 \
-y recording.mkv &
}
if test "$1" = start; then
fish -ic 'set -U AUDIO record'
record &
disown
else
fish -ic 'set -U AUDIO'
pkill ffmpeg
fi

View File

@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/sh
## WolframAlpha CLI