summaryrefslogtreecommitdiff
path: root/record
blob: 1430df2989f275930ff528b1fdac3f4ed34000e0 (plain)
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
#!/bin/sh

# record: Record an mp4 video using ffmpeg. By default it will output the
# video to './out.mp4' at 1080p. On NixOS, ffmpeg requires Xcb support.

set -eu

while getopts ":r:h" args; do
  case "$args" in
    r) RESOLUTION="$OPTARG" ;;
    h) echo "Usage: record [-r RESOLUTION] FILE" >&2
       exit 1
       ;;
    *) printf "Invalid option: -%s\nSee '-h' for usage\n" "$OPTARG" >&2
       exit 1
       ;;
  esac
done
shift $((OPTIND - 1))

FILE="${1:-out}"
: "${RESOLUTION:=1920x1080}"

ffmpeg -y -f x11grab -s "$RESOLUTION" -framerate 60 -i :0.0 -f alsa \
       -i default -nostats -hide_banner -loglevel quiet "${FILE}.mp4"