Add screencast, webmconvert to alias.sh

This commit is contained in:
Riyyi
2020-07-10 00:40:34 +02:00
parent f015000150
commit 4223dbbcc7
3 changed files with 70 additions and 21 deletions
+59 -13
View File
@@ -1,5 +1,9 @@
#!/bin/sh
depend() {
pactree -u -d 1 "$1" | tail -n +2 | sort
}
emacs() {
# Create new frame if (there isnt one || no file specified)
if [ -z "$(pgrep emacsclient)" ] || [ "$1" = "" ]; then
@@ -9,8 +13,14 @@ emacs() {
fi
}
depend() {
pactree -u -d 1 "$1" | tail -n +2 | sort
# $1 = find, $2 = list, $3 = list separator
in_list() {
[ -z "$1" ] || [ -z "$2" ] && return 1
if ! echo "$2" | awk -v m="^$1$" -v RS="${3:-' '}" '$0 ~ m { exit 1 }'; then
return 0
else
return 1
fi
}
java_doc() {
@@ -24,6 +34,14 @@ java_run () {
java -cp './out' "$1"
}
mkcd(){
mkdir -p "$1" && cd "$1" || exit
}
pastebin() {
echo "$1" | curl -F 'f:1=<-' ix.io
}
raspbian() {
sudo systemctl start avahi-daemon.service
if ! ip a show usb0 | grep -q 'inet6'; then
@@ -33,24 +51,52 @@ raspbian() {
sudo systemctl stop avahi-daemon.service
}
# $1 = find, $2 = list, $3 = list separator
in_list() {
[ -z "$1" ] || [ -z "$2" ] && return 1
if ! echo "$2" | awk -v m="^$1$" -v RS="${3:-' '}" '$0 ~ m { exit 1 }'; then
return 0
screencast() {
IS_RUNNING="$(pgrep ffmpeg)"
if [ "$IS_RUNNING" != "" ]; then
notify-send "Stopped recording.."
# Kill with SIGTERM, allowing finishing touches
pkill -15 ffmpeg
sleep 3
# Kill with SIGKILL, just in case it is still running
pkill -9 ffmpeg
else
return 1
NAME=${1:-"output"}
[ -n "$2" ] && AUDIO_CODEC="-c:a aac"
[ -n "$2" ] && AUDIO_SOURCE="-f pulse -ac 2 -i $2" # 1 = system, 2 = mic
notify-send "Started recording.."
ffmpeg -y \
-threads 4 \
-f x11grab \
-framerate 24 \
-s 3000x2000 \
-i "$DISPLAY.0" \
$AUDIO_SOURCE \
-r 24 \
-vf scale=1500:1000 \
$AUDIO_CODEC \
-c:v libx264 -crf 0 -preset ultrafast \
"$NAME.mkv" &
fi
}
pastebin() {
echo "$1" | curl -F 'f:1=<-' ix.io
}
stream() {
[ -z "$2" ] && QUALITY="720p" || QUALITY="$2"
QUALITY=${2:-"720p"}
streamlink --player mpv "https://twitch.tv/$1" "$QUALITY" > /dev/null 2>&1 &
}
webmconvert() {
[ "$2" = "1" ] && AUDIO="-c:a libvorbis" || AUDIO="-an"
# https://trac.ffmpeg.org/wiki/Encode/H.264
# https://trac.ffmpeg.org/wiki/Encode/VP8
# -qmin 0 (0-63, default 4, lower = better quality)
# -qmax 40 (qmin-63, default 63)
# -crf 16 (0-51, default 23, 0 = lossless)
# -b:v 4M
ffmpeg -threads 4 -i "$1" -c:v libvpx -qmin 0 -qmax 40 -crf 16 -b:v 4M "$AUDIO" "${1%.*}_convert.webm"
}
"$@"