first commit
This commit is contained in:
32
cam
Executable file
32
cam
Executable file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# cam: snap a frame from /dev/video0. press s to capture, q to cancel.
|
||||||
|
# cam -> clipboard
|
||||||
|
# cam photo.png -> file
|
||||||
|
|
||||||
|
if [ -n "$1" ]; then
|
||||||
|
out=$1
|
||||||
|
keep=1
|
||||||
|
else
|
||||||
|
out=$(mktemp --suffix=.png)
|
||||||
|
keep=
|
||||||
|
fi
|
||||||
|
conf=$(mktemp)
|
||||||
|
trap 'rm -f "$conf"; [ -z "$keep" ] && rm -f "$out"' EXIT
|
||||||
|
|
||||||
|
printf 's screenshot-to-file "%s" ; quit\n' "$out" > "$conf"
|
||||||
|
|
||||||
|
mpv av://v4l2:/dev/video0 \
|
||||||
|
--demuxer-lavf-format=video4linux2 \
|
||||||
|
--demuxer-lavf-o=input_format=mjpeg,video_size=1280x720 \
|
||||||
|
--profile=low-latency \
|
||||||
|
--force-window=immediate \
|
||||||
|
--geometry=50%:50% \
|
||||||
|
--input-conf="$conf" \
|
||||||
|
--title=cam --osd-msg1="s: snap q: cancel" \
|
||||||
|
--really-quiet 2>/dev/null
|
||||||
|
|
||||||
|
[ -s "$out" ] || exit 0
|
||||||
|
[ -n "$keep" ] && exit 0
|
||||||
|
|
||||||
|
xclip -selection clipboard -t image/png -loops 1 < "$out" &
|
||||||
|
sleep 0.1
|
||||||
29
camv
Executable file
29
camv
Executable file
@@ -0,0 +1,29 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# camv: preview /dev/video0; s to start recording, q to stop.
|
||||||
|
# camv -> /tmp/cam-<date>.mp4
|
||||||
|
# camv movie.mp4 -> save to that path
|
||||||
|
|
||||||
|
out=${1:-/tmp/cam-$(date +%Y%m%d-%H%M%S).mp4}
|
||||||
|
raw=$(mktemp --suffix=.mkv)
|
||||||
|
conf=$(mktemp)
|
||||||
|
trap 'rm -f "$conf" "$raw"' EXIT
|
||||||
|
|
||||||
|
printf 's set stream-record "%s" ; show-text REC\n' "$raw" > "$conf"
|
||||||
|
|
||||||
|
mpv av://v4l2:/dev/video0 \
|
||||||
|
--demuxer-lavf-format=video4linux2 \
|
||||||
|
--demuxer-lavf-o=input_format=mjpeg,video_size=640x480 \
|
||||||
|
--profile=low-latency \
|
||||||
|
--force-window=immediate \
|
||||||
|
--geometry=50%:50% \
|
||||||
|
--input-conf="$conf" \
|
||||||
|
--title=camv --osd-msg1="s: rec q: stop" \
|
||||||
|
--really-quiet 2>/dev/null
|
||||||
|
|
||||||
|
[ -s "$raw" ] || exit 0
|
||||||
|
|
||||||
|
ffmpeg -hide_banner -loglevel fatal -nostdin \
|
||||||
|
-vaapi_device /dev/dri/renderD128 -i "$raw" \
|
||||||
|
-vf 'format=nv12,hwupload' \
|
||||||
|
-c:v h264_vaapi -qp 28 -y "$out"
|
||||||
|
echo "$out"
|
||||||
26
scr
Executable file
26
scr
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if ! command -v slop >/dev/null; then
|
||||||
|
echo "scr: slop not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
copy=0
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
copy=1
|
||||||
|
out=$(mktemp --suffix=.png)
|
||||||
|
else
|
||||||
|
out=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
coords=$(slop -f "%x %y %w %h" 2>/dev/null) || exit 1
|
||||||
|
read x y w h <<<"$coords"
|
||||||
|
|
||||||
|
ffmpeg -f x11grab -loglevel error -s ${w}x${h} \
|
||||||
|
-i ${DISPLAY}+${x},${y} -frames:v 1 -y "$out"
|
||||||
|
|
||||||
|
if [ $copy -eq 1 ]; then
|
||||||
|
xclip -selection clipboard -t image/png -i "$out"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$out"
|
||||||
41
scrv
Executable file
41
scrv
Executable file
@@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Video Quality
|
||||||
|
# The range of the CRF scale is 0–51, where 0 is lossless, 23 is the default,
|
||||||
|
# and 51 is worst quality possible. A lower value generally leads to higher
|
||||||
|
# quality, and a subjectively sane range is 17–28
|
||||||
|
QUALITY=28
|
||||||
|
|
||||||
|
if ! command -v slop &> /dev/null
|
||||||
|
then
|
||||||
|
echo "slop command not found. Please install slop."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
echo "Usage: $0 <output.mp4>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
filename="$1"
|
||||||
|
|
||||||
|
echo "Select the desktop area to record."
|
||||||
|
coords=$(slop -f "%x %y %w %h" 2>/dev/null)
|
||||||
|
|
||||||
|
x=$(echo $coords | awk '{print $1}')
|
||||||
|
y=$(echo $coords | awk '{print $2}')
|
||||||
|
width=$(echo $coords | awk '{print $3}')
|
||||||
|
height=$(echo $coords | awk '{print $4}')
|
||||||
|
|
||||||
|
width=$((width / 2 * 2))
|
||||||
|
height=$((height / 2 * 2))
|
||||||
|
|
||||||
|
echo "Recording started. Press 'q' to stop recording."
|
||||||
|
|
||||||
|
#\#-f alsa -i pulse -c:v libx264 -preset ultrafast -crf ${QUALITY} \
|
||||||
|
#-c:v libx264 -preset ultrafast -crf ${QUALITY} \
|
||||||
|
#-tune zerolatency -pix_fmt yuv420p -f mp4 $filename
|
||||||
|
ffmpeg -f x11grab -loglevel quiet -s ${width}x${height} -i ${DISPLAY}+$x,$y \
|
||||||
|
-c:v libx264 -pix_fmt yuv420p -crf ${QUALITY} -preset ultrafast -f mp4 $filename
|
||||||
|
|
||||||
|
echo "Recording stopped."
|
||||||
16
trk
Executable file
16
trk
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# trk — translate English↔Korean, direction picked from input.
|
||||||
|
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
text=$*
|
||||||
|
else
|
||||||
|
text=$(cat)
|
||||||
|
fi
|
||||||
|
|
||||||
|
if printf '%s' "$text" | grep -qP '[\x{AC00}-\x{D7A3}\x{3131}-\x{3163}]'; then
|
||||||
|
pair=ko:en
|
||||||
|
else
|
||||||
|
pair=en:ko
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec trans -b "$pair" "$text"
|
||||||
Reference in New Issue
Block a user