-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreenrecord
More file actions
executable file
·77 lines (65 loc) · 1.51 KB
/
screenrecord
File metadata and controls
executable file
·77 lines (65 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
print_help()
{
echo "Usage: $(basename "$0") [options] [output_file]"
echo "Screen records with ffmpeg using the x11grab backend"
echo ""
echo "Example: $0 -s 1920x1080 -r 60 -o 128,0 -f ./video.mkv"
echo ""
echo "Required options:"
echo " -s Output resolution"
echo " -r Output FPS / refreshrate"
echo " -f Output file path"
echo ""
echo "Option options:"
echo " -o Recording position offset from the top left corner of the left-most screen"
echo " -a Audio source (something from 'pactl get-default-sink')"
}
start_recording()
{
ffmpeg -video_size "$RESOLUTION" -framerate "$FPS" -f x11grab -i :0.0+"$OFFSET" -f pulse -ac 2 -i "$AUDIO_SOURCE" -c:v libx264 -preset ultrafast -qp 17 -vf format=yuv420p "$OUTPUT"
}
# If there were no args specified, simply print the help page
[ $# -eq 0 ] && print_help
# Set default values for optional arguments
OFFSET="0,0"
AUDIO_SOURCE="$(pactl get-default-sink).monitor"
# Handle script arguments
while test $# -gt 0; do
case $1 in
-s)
shift
RESOLUTION="$1"
shift
;;
-r)
shift
FPS="$1"
shift
;;
-o)
shift
OFFSET="$1"
shift
;;
-a)
shift
AUDIO_SOURCE="$1"
shift
;;
-f)
shift
OUTPUT="$1"
shift
;;
*)
print_help
exit 0
;;
esac
done
# Check if required args were set
[ -z "$RESOLUTION" ] && echo "Resolution was not specified" && exit 1
[ -z "$FPS" ] && echo "FPS was not specified" && exit 1
[ -z "$OUTPUT" ] && echo "Output path was not specified" && exit 1
start_recording