screen recording

master
Daniel Napora 2022-10-01 01:41:08 +02:00
parent d20a88d501
commit 0f4a003365
2 changed files with 153 additions and 1 deletions

View File

@ -844,6 +844,16 @@ case $LANG in
BACK="wróć"
OPEN_SCR_DIR="Otwórz katalog ze zrzutami ekranu"
CANCEL="Anuluj"
SCRNREC="Nagrywanie pulpitu"
FULLREC="Pełny ekran"
AREA="Obszar lub okno"
VIDEOSETTINGS="Ustawienia nagrywania"
AUDIO="Dźwięk"
FORMAT="Kontener (rozszerzenie)"
FRAMERATE="Klatki na sekundę (fps)"
REC_AUDIO="Nagrywaj dźwięk"
NO_AUDIO="Bez dźwięku"
OPEN_REC_DIR="Otwórz katalog z nagraniami"
;;
es*)
SCRNSHOTS="Captura Pantalla"
@ -857,9 +867,12 @@ case $LANG in
BACK="atrás"
OPEN_SCR_DIR="Abrir carpeta de capturas"
CANCEL="Cancelar"
SCRNREC="Screen recording"
FULLREC="Full screen "
AREA="Selected Area or Window"
;;
*)
SCRNSHOTS="Screenshot tool"
SCRNSHOTS="Screenshot"
FULLSCR="Full screen"
ACTIVE_WIN="Active window"
ACTIVE_WIN_NO_DECOR="Active window (no decorations)"
@ -870,6 +883,16 @@ case $LANG in
BACK="back"
OPEN_SCR_DIR="Open screenshot directory"
CANCEL="Cancel"
SCRNREC="Screen recording"
FULLREC="Full screen "
AREA="Selected Area or Window"
VIDEOSETTINGS="Recording settings"
AUDIO="Audio"
FORMAT="Container (file extension)"
FRAMERATE="Framerate (fps)"
REC_AUDIO="Record Audio"
NO_AUDIO="No Audio"
OPEN_REC_DIR="Open recordings dir"
;;
esac
jgtools_padding=${jgtools_padding:-0}
@ -892,6 +915,32 @@ VIEW="'viewnior $IMG'"
THUMB="$(DISPLAY=:0 scrot -t 340x213 -o $HOME/.config/mabox/jgscrot.png -e 'echo $m')"
# Video recordings
CNF_FILE="$HOME"/.config/mabox/mb-screenrec.conf
if [ ! -f $CNF_FILE ]; then
cat <<EOF > ${CNF_FILE}
# Container (file extension): webm,mp4 or mkv
container=webm
# Record Audio? yes or no
record_audio=no
#Framerate (frames per second)
framerate=30
EOF
fi
. "$CNF_FILE"
if [ "$record_audio" == "yes" ];then
case "$LANG" in
pl*) AUD="z dźwiękiem";;
*) AUD="audio";;
esac
else
case "$LANG" in
pl*) AUD="bez dźwięku";;
*) AUD="noaudio";;
esac
fi
mkconfigfile
cat <<EOF > ${MENU_ITEMS}
@ -905,6 +954,13 @@ cat <<EOF > ${MENU_ITEMS}
#  Multimonitor, scrot -m $IMG -e $VIEW
^sep()
 $OPEN_SCR_DIR,xdg-open $(xdg-user-dir PICTURES)/screenshots
^sep($SCRNREC)
 $FULLREC,mb-screenrec -f
 $AREA,mb-screenrec -a
^sep()
 $VIDEOSETTINGS [ <small><b>$container</b> / <b>${AUD}</b> / <b>$framerate fps</b></small> ],^checkout(videosettings)
 $OPEN_REC_DIR,xdg-open $(xdg-user-dir VIDEOS)/Recordings
^sep()
 $CANCEL <small>esc</small>,exit 1
^tag(full)
@ -928,6 +984,25 @@ cat <<EOF > ${MENU_ITEMS}
 $SEC10,scrot -d 10 -u $IMG -e $VIEW
^sep()
⮜ $BACK,^back()
^tag(videosettings)
^sep($VIDEOSETTINGS)
$AUDIO [ <b>${AUD}</b> ],^checkout(audio)
$FORMAT [ <b>${container}</b> ],^checkout(format)
$FRAMERATE [ <b>${framerate}</b> ],^checkout(framerate)
^tag(audio)
^sep($AUDIO)
$REC_AUDIO,mb-setvar record_audio=yes ${CNF_FILE};mb-jgtools screenshot ipc
$NO_AUDIO,mb-setvar record_audio=no ${CNF_FILE};mb-jgtools screenshot ipc
^tag(format)
^sep($FORMAT)
webm,mb-setvar container=webm ${CNF_FILE};mb-jgtools screenshot ipc
mkv,mb-setvar container=mkv ${CNF_FILE};mb-jgtools screenshot ipc
mp4,mb-setvar container=mp4 ${CNF_FILE};mb-jgtools screenshot ipc
^tag(framerate)
^sep($FRAMERATE)
30,mb-setvar framerate=30 ${CNF_FILE};mb-jgtools screenshot ipc
25,mb-setvar framerate=25 ${CNF_FILE};mb-jgtools screenshot ipc
24,mb-setvar framerate=24 ${CNF_FILE};mb-jgtools screenshot ipc
EOF
jgmenu --config-file=${CONFIG_FILE} --csv-file=${MENU_ITEMS} 2>/dev/null
}

77
bin/mb-screenrec 100755
View File

@ -0,0 +1,77 @@
#!/bin/bash
#: mb-screenrec - very simple screen recorder
CNF_FILE="$HOME"/.config/mabox/mb-screenrec.conf
. "$CNF_FILE"
DATE=$(date +%Y%m%d_%H-%M-%S)
FRAMERATE=${framerate:-30}
EXT=${container:-webm}
AUDIO=${record_audio:-no}
SCREEN_SIZE=$(xdpyinfo | awk '/^ +dimensions/ {print $2}')
# Alternative: xrandr | grep 'current' | head -n1 | cut -d',' -f2 | tr -d '[:blank:],current'
RECDIR="$(xdg-user-dir VIDEOS)/Recordings"
mkdir -p $RECDIR
if [ "$AUDIO" == "yes" ];then
AUDIOCMD="-f pulse -ac 2 -i default"
else
AUDIOCMD=""
fi
show_stop_icon () {
case "$LANG" in
pl*) STOP_INFO="Zatrzymaj nagrywanie";;
*) STOP_INFO="Click to stop recording";;
esac
yad --notification --image media-playback-stop --text "${STOP_INFO}"
kill $FFMPEG_PID
wait $FFMPEG_PID
xdg-open $RECDIR
}
rec_full () {
ffmpeg -f x11grab \
-video_size $SCREEN_SIZE \
-framerate $FRAMERATE \
-i :0.0+0,0 ${AUDIOCMD} \
${RECDIR}/rec_${DATE}.${EXT} &
FFMPEG_PID=$!
show_stop_icon
}
get_area () {
read X Y W H <<<"$(slop -l -b 3 --color=0.3,0.4,0.6,0.4 -f '%x %y %w %h')"
}
sel_cancelled () {
notify-send.sh -i mbcc "Error" "Selection was cancelled by keystroke or right-click."
}
rec_area () {
get_area
if [ "$X" != "" ];then
ffmpeg -f x11grab \
-video_size ${W}x${H} \
-framerate $FRAMERATE \
-i :0.0+${X},${Y} ${AUDIOCMD} \
${RECDIR}/rec_${DATE}.${EXT} &
FFMPEG_PID=$!
show_stop_icon
else
sel_cancelled
fi
}
case "$1" in
-f|--fullscreen) rec_full;;
-a|--area) rec_area;;
*) ;;
esac