update recording script
This commit is contained in:
parent
b10eaef3e0
commit
65426e1e5d
|
@ -3,6 +3,7 @@
|
||||||
TMP_FILE_UNOPTIMIZED="/tmp/recording_unoptimized.gif"
|
TMP_FILE_UNOPTIMIZED="/tmp/recording_unoptimized.gif"
|
||||||
TMP_PALETTE_FILE="/tmp/palette.png"
|
TMP_PALETTE_FILE="/tmp/palette.png"
|
||||||
TMP_MP4_FILE="/tmp/recording.mp4"
|
TMP_MP4_FILE="/tmp/recording.mp4"
|
||||||
|
TMP_GIF_RESULT="/tmp/gif_result"
|
||||||
APP_NAME="Recorder"
|
APP_NAME="Recorder"
|
||||||
|
|
||||||
OUT_DIR="$HOME/Videos"
|
OUT_DIR="$HOME/Videos"
|
||||||
|
@ -26,7 +27,7 @@ convert_to_gif() {
|
||||||
if [ -f "$TMP_MP4_FILE" ]; then
|
if [ -f "$TMP_MP4_FILE" ]; then
|
||||||
rm "$TMP_MP4_FILE"
|
rm "$TMP_MP4_FILE"
|
||||||
fi
|
fi
|
||||||
gifsicle -O3 --lossy=100 -i "$TMP_FILE_UNOPTIMIZED" -o "$FILENAME"
|
gifsicle -O3 --lossy=100 -i "$TMP_FILE_UNOPTIMIZED" -o "$TMP_GIF_RESULT"
|
||||||
if [ -f "$TMP_FILE_UNOPTIMIZED" ]; then
|
if [ -f "$TMP_FILE_UNOPTIMIZED" ]; then
|
||||||
rm "$TMP_FILE_UNOPTIMIZED"
|
rm "$TMP_FILE_UNOPTIMIZED"
|
||||||
fi
|
fi
|
||||||
|
@ -37,12 +38,14 @@ notify() {
|
||||||
}
|
}
|
||||||
|
|
||||||
screen() {
|
screen() {
|
||||||
|
notify "Starting Recording" "Your screen is being recorded"
|
||||||
timeout 600 wf-recorder -F format=rgb24 -x rgb24 -p qp=0 -p crf=0 -p preset=slow -c libx264rgb -f "$TMP_MP4_FILE"
|
timeout 600 wf-recorder -F format=rgb24 -x rgb24 -p qp=0 -p crf=0 -p preset=slow -c libx264rgb -f "$TMP_MP4_FILE"
|
||||||
}
|
}
|
||||||
|
|
||||||
area() {
|
area() {
|
||||||
GEOMETRY=$(slurp)
|
GEOMETRY=$(slurp)
|
||||||
if [[ ! -z "$GEOMETRY" ]]; then
|
if [[ ! -z "$GEOMETRY" ]]; then
|
||||||
|
notify "Starting Recording" "Your screen is being recorded"
|
||||||
timeout 600 wf-recorder -F format=rgb24 -x rgb24 -p qp=0 -p crf=0 -p preset=slow -c libx264rgb -g "$GEOMETRY" -f "$TMP_MP4_FILE"
|
timeout 600 wf-recorder -F format=rgb24 -x rgb24 -p qp=0 -p crf=0 -p preset=slow -c libx264rgb -g "$GEOMETRY" -f "$TMP_MP4_FILE"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -60,17 +63,29 @@ stop() {
|
||||||
notify "Stopped Recording" "Starting GIF conversion phase..."
|
notify "Stopped Recording" "Starting GIF conversion phase..."
|
||||||
FILENAME+="gif"
|
FILENAME+="gif"
|
||||||
convert_to_gif
|
convert_to_gif
|
||||||
wl-copy -t image/png < $FILENAME
|
SavePath=$( zenity --file-selection --save --file-filter=*.gif --filename="$OUT_DIR"'/.gif' )
|
||||||
notify "GIF conversion completed" "GIF saved to $FILENAME"
|
if [ "$SavePath" == "" ]; then
|
||||||
|
SavePath="$FILENAME"
|
||||||
|
fi
|
||||||
|
[[ $SavePath =~ \.gif$ ]] || SavePath+='.gif'
|
||||||
|
mv $TMP_GIF_RESULT $SavePath
|
||||||
|
wl-copy -t image/png < $SavePath
|
||||||
|
notify "GIF conversion completed" "GIF saved to $SavePath"
|
||||||
else
|
else
|
||||||
FILENAME+="mp4"
|
FILENAME+="mp4"
|
||||||
mv $TMP_MP4_FILE $FILENAME
|
SavePath=$( zenity --file-selection --save --file-filter=*.mp4 --filename="$OUT_DIR"'/.mp4' )
|
||||||
wl-copy -t video/mp4 < $FILENAME
|
if [ "$SavePath" == "" ]; then
|
||||||
notify "Stopped Recording" "Video saved to $FILENAME"
|
SavePath="$FILENAME"
|
||||||
|
fi
|
||||||
|
[[ $SavePath =~ \.mp4$ ]] || SavePath+='.mp4'
|
||||||
|
mv $TMP_MP4_FILE $SavePath
|
||||||
|
wl-copy -t video/mp4 < $SavePath
|
||||||
|
notify "Stopped Recording" "Video saved to $SavePath"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[[ -f $TMP_FILE_UNOPTIMIZED ]] && rm -f "$TMP_FILE_UNOPTIMIZED"
|
[[ -f $TMP_FILE_UNOPTIMIZED ]] && rm -f "$TMP_FILE_UNOPTIMIZED"
|
||||||
[[ -f $TMP_PALETTE_FILE ]] && rm -f "$TMP_PALETTE_FILE"
|
[[ -f $TMP_PALETTE_FILE ]] && rm -f "$TMP_PALETTE_FILE"
|
||||||
|
[[ -f $TMP_GIF_RESULT ]] && rm -f "$TMP_GIF_RESULT"
|
||||||
[[ -f $TMP_MP4_FILE ]] && rm -f "$TMP_MP4_FILE"
|
[[ -f $TMP_MP4_FILE ]] && rm -f "$TMP_MP4_FILE"
|
||||||
[[ -f /tmp/recording_gif ]] && rm -f /tmp/recording_gif
|
[[ -f /tmp/recording_gif ]] && rm -f /tmp/recording_gif
|
||||||
|
|
||||||
|
@ -85,6 +100,7 @@ fi
|
||||||
if [ "$1" != "stop" ]; then
|
if [ "$1" != "stop" ]; then
|
||||||
[[ -f $TMP_FILE_UNOPTIMIZED ]] && rm -f "$TMP_FILE_UNOPTIMIZED"
|
[[ -f $TMP_FILE_UNOPTIMIZED ]] && rm -f "$TMP_FILE_UNOPTIMIZED"
|
||||||
[[ -f $TMP_PALETTE_FILE ]] && rm -f "$TMP_PALETTE_FILE"
|
[[ -f $TMP_PALETTE_FILE ]] && rm -f "$TMP_PALETTE_FILE"
|
||||||
|
[[ -f $TMP_GIF_RESULT ]] && rm -f "$TMP_GIF_RESULT"
|
||||||
[[ -f $TMP_MP4_FILE ]] && rm -f "$TMP_MP4_FILE"
|
[[ -f $TMP_MP4_FILE ]] && rm -f "$TMP_MP4_FILE"
|
||||||
[[ -f /tmp/recording_gif ]] && rm -f /tmp/recording_gif
|
[[ -f /tmp/recording_gif ]] && rm -f /tmp/recording_gif
|
||||||
fi
|
fi
|
||||||
|
@ -103,7 +119,7 @@ case "$1" in
|
||||||
stop
|
stop
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Usage: record {screen|area|gif|stop}"
|
echo "Usage: $0 {screen|area|gif|stop}"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue