update recording script
This commit is contained in:
parent
b10eaef3e0
commit
65426e1e5d
|
@ -3,6 +3,7 @@
|
|||
TMP_FILE_UNOPTIMIZED="/tmp/recording_unoptimized.gif"
|
||||
TMP_PALETTE_FILE="/tmp/palette.png"
|
||||
TMP_MP4_FILE="/tmp/recording.mp4"
|
||||
TMP_GIF_RESULT="/tmp/gif_result"
|
||||
APP_NAME="Recorder"
|
||||
|
||||
OUT_DIR="$HOME/Videos"
|
||||
|
@ -26,7 +27,7 @@ convert_to_gif() {
|
|||
if [ -f "$TMP_MP4_FILE" ]; then
|
||||
rm "$TMP_MP4_FILE"
|
||||
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
|
||||
rm "$TMP_FILE_UNOPTIMIZED"
|
||||
fi
|
||||
|
@ -37,12 +38,14 @@ notify() {
|
|||
}
|
||||
|
||||
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"
|
||||
}
|
||||
|
||||
area() {
|
||||
GEOMETRY=$(slurp)
|
||||
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"
|
||||
fi
|
||||
}
|
||||
|
@ -60,17 +63,29 @@ stop() {
|
|||
notify "Stopped Recording" "Starting GIF conversion phase..."
|
||||
FILENAME+="gif"
|
||||
convert_to_gif
|
||||
wl-copy -t image/png < $FILENAME
|
||||
notify "GIF conversion completed" "GIF saved to $FILENAME"
|
||||
SavePath=$( zenity --file-selection --save --file-filter=*.gif --filename="$OUT_DIR"'/.gif' )
|
||||
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
|
||||
FILENAME+="mp4"
|
||||
mv $TMP_MP4_FILE $FILENAME
|
||||
wl-copy -t video/mp4 < $FILENAME
|
||||
notify "Stopped Recording" "Video saved to $FILENAME"
|
||||
SavePath=$( zenity --file-selection --save --file-filter=*.mp4 --filename="$OUT_DIR"'/.mp4' )
|
||||
if [ "$SavePath" == "" ]; then
|
||||
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
|
||||
|
||||
[[ -f $TMP_FILE_UNOPTIMIZED ]] && rm -f "$TMP_FILE_UNOPTIMIZED"
|
||||
[[ -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/recording_gif ]] && rm -f /tmp/recording_gif
|
||||
|
||||
|
@ -85,6 +100,7 @@ fi
|
|||
if [ "$1" != "stop" ]; then
|
||||
[[ -f $TMP_FILE_UNOPTIMIZED ]] && rm -f "$TMP_FILE_UNOPTIMIZED"
|
||||
[[ -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/recording_gif ]] && rm -f /tmp/recording_gif
|
||||
fi
|
||||
|
@ -103,7 +119,7 @@ case "$1" in
|
|||
stop
|
||||
;;
|
||||
*)
|
||||
echo "Usage: record {screen|area|gif|stop}"
|
||||
echo "Usage: $0 {screen|area|gif|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
Loading…
Reference in a new issue